Where … In … Or Where … In … with NHibernate IQueryOver

余生长醉 提交于 2019-12-21 09:26:52

问题


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);

This, however, generates an and query, whereas I need to have an or operator between two where clauses.

How is this done with IQueryOver?


回答1:


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)));


来源:https://stackoverflow.com/questions/6019645/where-in-or-where-in-with-nhibernate-iqueryover

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!