问题
I want to create a query which has more than 3-4 Expression.Or ? But Expression.Or just let me to add two Expressions inside it.
if (!string.IsNullOrEmpty(keyword))
query
.Add(Expression.Or(
Expression.Like("Name", keyword, MatchMode.Anywhere),
Expression.Like("LastName", keyword, MatchMode.Anywhere)))
.Add(Expression.Or(
Expression.Like("Email1", keyword, MatchMode.Anywhere),
Expression.Like("Email2", keyword, MatchMode.Anywhere)));
The code above generates "Name like %this% or LastName like %this% AND Email1 like %this% and Email2 like %this.
Thanks in advance.
回答1:
Use Disjunction instead of Or.
回答2:
You can also use || instead of Or( ) or Disjunction( ).
来源:https://stackoverflow.com/questions/434138/how-to-set-more-than-2-expression-in-expression-or