Come impostare più di 2 espressioni in Expression.Or
-
10-07-2019 - |
Domanda
Voglio creare una query con più di 3-4 espressioni. Oppure? Ma Expression. O fammi solo aggiungere due espressioni al suo interno.
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)));
Il codice sopra genera " Nome come% this% o Cognome come% this% AND Email1 come% this% e Email2 come% this.
Grazie in anticipo.
Soluzione
Usa Disjunction invece di Or.
Altri suggerimenti
Puoi anche usare || invece di Or () o Disjunction ().
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow