似乎NHibernate Linq不了解分组。所以方法条件。我得到了以下代码:
var q = from o in session.Query<OrdreLinjeVerdier>()
where o.OrdreLinjeReserve > 0
group o by o.ProduktLager.ProduktLagerID into g
select new
{
ProduktLagerID = g.Key,
OrdreRes = g.Sum(x => x.OrdreLinjeReserve),
OrdreResUtenSpesial =
g.Where(x => x.LeveringsType.LeveringsTypeID == 1)
.Sum(x => (double?)x.OrdreLinjeReserve)
};
它就像这样对数据库:
select ordrelinje0_.ProduktLagerID as col_0_0_,
cast(sum(ordrelinje0_.OrdreLinjeReserve) as DECIMAL(19,5)) as col_1_0_,
cast(sum(ordrelinje0_.OrdreLinjeReserve) as DOUBLE PRECISION) as col_2_0_
from OrdreLinjeVerdier ordrelinje0_
where ordrelinje0_.OrdreLinjeReserve>@p0
group by ordrelinje0_.ProduktLagerID;
@p0 = 0
基本上是g的条件。对SQL查询没有影响。
好像是虫子还是我错过了什么?