queryover和(x代表'a'或y代表'a') [英] queryover and (x like 'a' or y like 'a')
本文介绍了queryover和(x代表'a'或y代表'a')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨 当我使用queryover API时,是否有任何优雅的方式将"like"和"or"组合在一起? 对于喜欢",有类似的东西:
Hi Is there any elegant way of combining 'like' and 'or' when i'm using queryover API? for 'like' there is something like:
query.WhereRestrictionOn(x=>x.Code).IsLike(codePart)
对于或",我可以做类似的事情:
for 'or' i can do something like:
query.Where( x=>x.Code == codePart || x.Description== codePart)
但是如何创建这样的查询:
but how can I create a query like this:
从n中选择*,其中代码类似于 '%abc%'或类似'%abc%'的描述
select * from n where code like '%abc%' or description like '%abc%'
推荐答案
query.Where(Restrictions.On<Type>(x => x.Code).IsLike(codePart) ||
Restrictions.On<Type>(x => x.Description).IsLike(codePart))
这篇关于queryover和(x代表'a'或y代表'a')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文