Sasha
Sasha

Reputation: 20834

why can't i use like and equal operators together in my search query

what i'm trying to do it's simple search by three columns: firstname, lastname and email

in my case i need that two first colums (firstname and lastname) will be searchable by like operator and the last one (email) by equal operator

but im getting error that does not explain what should i do:

Screenshot with no freehand circles or arrows.

in plain sql it should be something like this:

Select *
From Member
Where FirstName like '%value%' Or LastName like '%value%' Or Email='value'

but what im doing wrong?

Upvotes: 1

Views: 511

Answers (1)

Faber
Faber

Reputation: 2194

You can try with

.Where(Restrictions.Disjunction()
     .Add(Restrictions.On(x => x.FirstName).IsLike(keyWord))
     .Add(Restrictions.On(x => x.LastName).IsLike(keyWord))
     .Add(Restrictions.On(x => x.FirstName).IsLike(keyWord))
     .Add(Restrictions.Eq(x.Email,keyWord))
 )

I hope it's helpful

Upvotes: 2

Related Questions