我想合并两个限制,一个与父母有关,一个与孩子有关。
我有以下代码:
var query = Session.QueryOver<Project>()
.Where(x => x.AccountId == Scope.AccountId)
.And(x => x.Archived != active)
.AndRestrictionOn(x => x.Name).IsLike("%" + text + "%")
.JoinQueryOver(x => x.Customer)
.WhereRestrictionOn(c => c.Name).IsLike("%" + text + "%")
.OrderBy(x => x.Id).Desc
.Fetch(x => x.Customer).Eager;
SQL 输出:
SELECT this_.Id as Id2_1_,
this_.Account_id as Account2_2_1_,
this_.Name as Name2_1_,
this_.Info as Info2_1_,
this_.Archived as Archived2_1_,
this_.Customer_id as Customer6_2_1_,
customer1_.Id as Id1_0_,
customer1_.Account_id as Account2_1_0_,
customer1_.Name as Name1_0_
FROM [Project] this_
inner join [Customer] customer1_
on this_.Customer_id = customer1_.Id
WHERE this_.Account_id = 5 /* @p0 */
and not (this_.Archived = 1 /* @p1 */)
and this_.Name like '%dim%' /* @p2 */
and customer1_.Name like '%dim%' /* @p3 */
ORDER BY customer1_.Id desc
不幸的是,这两个限制之间存在 AND 结合:
this_.Name like '%dim%' and customer1_.Name like '%dim%'
我想要 OR 代替,像这样:
this_.Name like '%dim%' or customer1_.Name like '%dim%'
如何使用新的 QueryOver API 解决此查询?