Reputation: 20834
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:
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
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