在NHibernate的queryover中使用OR Clause
我正在使用Nhibernate。 我正在通过queryover方法编写查询。 我能够编写和编写如下面的代码。 它的工作正常。
db.QueryOver(Of Users)() .Where(Function(x) x.Role = "Guest") .And(Function(x) x.Block = 0) .And(Function(x) x.APPID = appId) .List();
但我想使用Or
子句代替And
,或两者的组合。 我该如何实现呢。 谢谢
这是描述我们如何与NHiberante建立OR
- 带有WhereRestriction的NHibernate QueryOver为OR
语法(在标签中用C#表示)是:
-
Restrictions.Or(restriction1, restriction1)
-
Restrictions.Disjunction().Add(restriction1).Add(restriction2).Add(...
在这种情况下,它可能是这样的(再次在C#中,而问题似乎使用VB) :
db.QueryOver()() .Where((x) => x.Role == "Guest") .And(Restrictions.Or( Restrictions.Where ((x) => x.Block == 0) , Restrictions.Where ((x) => x.APPID == appId) )) .List ();