views:

1410

answers:

2

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.

+6  A: 

Use Disjunction instead of Or.

Mauricio Scheffer
Thank you very much,I have another question. I want to query another table while querying this one. Forexample i want to get Customers whose id = Group.CustomerId
Barbaros Alp
Please create another question for that, it's unrelated to this one.
Mauricio Scheffer
+2  A: 

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

Caro