NHibernate Linq由条件组成

时间:2012-06-27 11:56:45

标签: linq nhibernate

似乎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查询没有影响。

好像是虫子还是我错过了什么?

1 个答案:

答案 0 :(得分:0)

对我来说这看起来像个错误。

使用最新的稳定版本(截至今天的3.3.1)确保发生这种情况后,请在https://nhibernate.jira.com

创建问题