开发者

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 f开发者_Python百科irst 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:

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

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜