将NHibernate中两个子查询的加法与QueryOver进行比较

时间:2016-03-02 03:40:08

标签: c# nhibernate orm queryover

如何创建两个子查询并添加计数以与属性进行比较?

这是我已经走了多远

Client clientAlias = null;
var subquery1 = QueryOver.Of<Car>()
    .Where(c => c.Client.Id == clientAlias.Id)
    .Where(c => c.Status == "Available");

var subquery1 = QueryOver.Of<Appartment>()
    .Where(a => a.Client.Id == clientAlias.Id)
    .Where(a => a.Size < 10);

var query = session.QueryOver<Client>(() => clientAlias);

这是如何在sql

中完成的
select *
from   Client c
where  (select count(*) from [Car] r where r.ClientId = c.Id and r.Status = 'Available') + (select count(*) from [Appartment] a where a.ClientId = c.Id and a.Size < 10) > c.Age

0 个答案:

没有答案