本文介绍了使用NHibernate IQueryOver在...或...中...在...中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用NHibernate的IQueryOver
模拟主题查询.到目前为止,我有
I'm trying to emulate subject query with NHibernate's IQueryOver
. So far I have
var q = CurrentSession.QueryOver<ObjectModel.Order>().
WhereRestrictionOn(o => o.Buyer.ID).IsIn(partyIDs).
WhereRestrictionOn(o => o.Seller.ID).IsIn(partyIDs);
但是,这会生成一个and
查询,而我需要在两个where
子句之间使用一个or
运算符.
This, however, generates an and
query, whereas I need to have an or
operator between two where
clauses.
如何使用IQueryOver
完成此操作?
How is this done with IQueryOver
?
推荐答案
通常,在向公众解释问题后很快就发现了问题.谢谢,伙计们!
As it usually is, found question soon after explaining the problem to general public. Thanks, guys!
var q = CurrentSession.QueryOver<ObjectModel.Order>();
q.RootCriteria.Add(Restrictions.Or(
Restrictions.On<ObjectModel.Order>(o => o.Buyer.ID).IsIn(partyIDs),
Restrictions.On<ObjectModel.Order>(o => o.Seller.ID).IsIn(partyIDs)));
这篇关于使用NHibernate IQueryOver在...或...中...在...中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!