queryover and (x like 'a' or y like 'a') [英] queryover and (x like 'a' or y like 'a')

查看:16
本文介绍了queryover and (x like 'a' or y like 'a')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨当我使用 queryover API 时,是否有任何优雅的方式组合喜欢"和或"?对于喜欢"有类似的东西:

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:

select * from n where code like%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 and (x like 'a' or y like 'a')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆