简体   繁体   中英

How to set more than 2 Expression in Expression.Or

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.

使用Disjunction而不是Or。

You can also use || instead of Or( ) or Disjunction( ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM