Hi,
Quick question on how to get even more out of PredicateBuilder. It works as per below:
IQueryable<Product> SearchProducts (params string[] keywords)
{
var predicate = PredicateBuilder.False<Product>();
foreach (string keyword in keywords)
{
string temp = keyword;
predicate = predicate.Or (p => p.Description.Contains (temp));
}
return dataContext.Products.Where (predicate);
}
The question is, what if I would like to search by an arbitrary member as well, ie pass the function string[] as the keywords, but also the field to search by, eg fieldToSearch, and replace the p=> p.Description.Contains(temp)); with something allowing searching by fieldToSearch?
Is this possible, is it a bad idea?