Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NHibernate with IQueryOver-使用子查询和或条件创建where条件_Nhibernate_Subquery_Criteria_Queryover_Icriteria - Fatal编程技术网

NHibernate with IQueryOver-使用子查询和或条件创建where条件

NHibernate with IQueryOver-使用子查询和或条件创建where条件,nhibernate,subquery,criteria,queryover,icriteria,Nhibernate,Subquery,Criteria,Queryover,Icriteria,当我这样做的时候 Acc accountAlias = null; var subQuery = QueryOver.Of<Temp>() .Where(x=>x.IsAccepted==null) .And(x=>x.Account.Id==accountAlias.Id); var results = session.QueryOver<Acc>(()=>accountAlias)

当我这样做的时候

Acc accountAlias = null;
var subQuery = QueryOver.Of<Temp>()
               .Where(x=>x.IsAccepted==null)
               .And(x=>x.Account.Id==accountAlias.Id);

var results = session.QueryOver<Acc>(()=>accountAlias)
              .Where(x=>x.User.Id==65)
              .WithSubquery.WhereExists(subQuery);
如何添加NHibernate将生成休闲sql的条件或条件:

select *
from Accounts a
where a.User_Id=65
and exists (
    select t.Account_Id
    from Temporary_Accounts t
    where t.IsAccepted is null and t.Account_Id=a.Account_Id)
select *
from Accounts a
where a.User_Id=65 
and (a.Amount = 100 or exists (
    select t.Account_Id
    from Temporary_Accounts t
    where t.IsAccepted is null and t.Account_Id=a.Account_Id))

未经测试,但类似tihs的东西可能会起作用

Acc accountAlias = null;
var subQuery = QueryOver.Of<Temp>()
               .Where(x => x.IsAccepted == null)
               .And(x => x.Account.Id == accountAlias.Id);

var results = session.QueryOver<Acc>(()=>accountAlias)
                  .Where(Restrictions.Disjunction()
                     .Add(Subqueries.WhereExists(subQuery))
                     .Add(x => x.Amount == 100))
                  .And(x => x.User.Id = 65)
                  .List();
Acc accountAlias=null;
var subQuery=QueryOver.Of()
。其中(x=>x.IsAccepted==null)
和(x=>x.Account.Id==accountAlias.Id);
var results=session.QueryOver(()=>accountAlias)
.Where(限制.析取()
.Add(子查询.WhereExists(子查询))
.Add(x=>x.Amount==100))
.和(x=>x.User.Id=65)
.List();