将两个子查询添加到使用 Or 运算符而不是 And 的查询中?

Add two sub queries to the query over with Or operator instead of And?

我试过了

incidentSubquery.WithSubquery.WhereProperty(x => x.Id).In (witnessTypesSubquery).
                 WithSubquery.WhereProperty(x => x.Id).NotIn(witnessTypesSubquery);

但是两个子查询之间的运算符是 And 运算符 我怎样才能用 or 运算符代替 and .

一种方法可以是:

incidentSubquery.Where
(
  Restrictions.Disjunction()
    .Add(Subqueries.WhereProperty<MyEntity>(x => x.Id).In(witnessTypesSubquery))
    .Add(Subqueries.WhereProperty<MyEntity>(x => x.Id).NotIn(witnessTypesSubquery))
);

我们可以使用Restrictions.Disjunction().Add(...).Add(...)连接尽可能多的OR语句。

简化版本可以使用 Restrictions.Or(A, B)(只有两个语句)