Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 529
Barbaros Alp Avatar asked Jan 12 '09 00:01

Barbaros Alp


People also ask

What is expression syntax?

Syntax is the set of rules by which the words and symbols in an expression are correctly combined. Initially, expressions in Access are a little bit hard to read. But with a good understanding of expression syntax and a little practice, it becomes much easier.

What is expression in JavaScript?

JavaScript's expression is a valid set of literals, variables, operators, and expressions that evaluate to a single value that is an expression. This single value can be a number, a string, or a logical value as depending on expression.


2 Answers

Use Disjunction instead of Or.

like image 97
Mauricio Scheffer Avatar answered Sep 19 '22 21:09

Mauricio Scheffer


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

like image 27
Caro Avatar answered Sep 21 '22 21:09

Caro