如何在nhibernate linq中获得列的总和

本文关键字:nhibernate linq | 更新日期: 2023-09-27 18:15:57

我应该如何写这样的查询:

SELECT SUM(c2) sum_c2, SUM(c3) sum_c3, SUM(c4) sum_c4 FROM tableT1 WHERE c1 = 'blablabla'

使用NHibernate (Linq或QueryOver或Criteria)得到一个一维的和数组?

如何在nhibernate linq中获得列的总和

tableT1.Where(t=>t.c1=="blablabla")
       .GroupBy(t=>1)
       .Select(g=>new{sum_c2=g.Sum(x=>x.c2),sum_c3=g.Sum(x=>x.c3),sum_c4=g.Sum(x=>x.c4)});