Disclaimer: I've solved the problem using Expressions from System.Linq.Expressions, but I'm still looking for a better/easier way.
Consider the following situation :
var query =
from c in db.Customers
where (c.ContactFirstName.Contains("BlackListed") ||
c.ContactLastName.Contains("BlackListed") ||
c.Address.Contains("BlackListed"))
select c;
The columns/attributes that need to be checked against the blacklisted term are only available to me at runtime. How do I generate this dynamic where clause?
An additional complication is that the Queryable collection (db.Customers above) is typed to a Queryable of the base class of 'Customer' (say 'Person'), and therefore writing c.Address as above is not an option.