Hi,
I am attempting to create a dynamic where clause using the standard expression API.
var query = (
from p in Parties
orderby p.PartyId
orderby p.FullName
select p
).AsQueryable();
Expression<Func<Party, bool>> @fn = (p) => SqlMethods.Like(p.FullName, "%smith%") || SqlMethods.Like(p.Person.FirstName, "%smith%");
Expression<Func<Party, bool>> @sn = (p) => SqlMethods.Like(p.Person.FirstName, words[0]);
ParameterExpression pe = Expression.Parameter(typeof(Party), "p");
Expression orelse = Expression.OrElse(
Expression.Lambda(@fn, pe),
Expression.Lambda(@sn, pe)
);
The expressions above will ultimately be added to a where clause. I need to add a bunch of 'likes'.
How do I do this?
I get InvalidOperationException on the operator OrElse
I have also tried Expression.Or
Thanks
Regards
Craig.