I have two queries that return a collection of the same object, after completing these two queries, I want to combine them.
var results = from t in All() where t.Blah.Contains(blahblah) select t; var results2 = from t in All() where t.blah2.contains(blahblah) select t; return results.Union(results2);
It is possible that the second query cannot return any results and will be null .
It seems that if I try to combine with two, if the second argument is null, it will throw an ArgumentNullException .
The obvious answer would be to simply execute .ToList() in the second query to see if it contains anything. The problem is that I am trying to use deferred execution and do not want to actually execute the query in the database at this point.
Is there any way around this?
Change - Solution
var results2 = from t in All() where t.blah2!=null && t.blah2.Contains(blahblah) select t;
Basically, the actual query returned null as I was trying to make a list in a null list
Thanks for the help!
source share