nerd speak for the software designer
Thursday, December 6, 2012
Creating Dynamic Predicates Using Predicate Builder
IQueryable
SearchProducts (params string[] keywords)
{
var predicate = PredicateBuilder.False
();
foreach (string keyword in keywords)
{
string temp = keyword;
predicate = predicate.Or (p => p.Description.Contains (temp));
}
return dataContext.Products.Where (predicate);
}
see
C# in a Nutshell
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment