好的,我在这个上输了。我有一个看起来像这样的NHibernate查询
var subQuery = QueryOver.Of<Lead>()
.Where(x => x.Client == user.Client)
.And(x => x.LeadType == leadType && x.LeadType != LeadTypeEnum.Self)
.Select(Projections.Distinct(Projections.Id()));
我用这个
var query = Session.QueryOver<Lead>()
.WithSubquery.WhereProperty(x => x.Id).In(subQuery);
这产生我需要的东西
Where lead.id in (select Id from .......)
但是,我需要添加另一个子查询。上面容易做,但我需要这个来产生以下
Where lead.id in (select id from .....)
or lead.id in (select id from .......)
问题是我总是得到以下
Where lead.id in (select id from .....)
and lead.id in (select id from .......)
有人可以指出我正确的方向来获取或
答案 0 :(得分:3)
我自己是NH新手,但您可能想尝试创建一个析取并向其添加条件,然后将该析取添加到QueryOver Where
调用。
var disjunction = new Disjunction();
disjunction.Add(subQuery1);
disjunction.Add(subQuery2);
var query = Session.QueryOver<Lead>()
.Where(disjunction);