LINQ--SQL分组查数量与字段的语句转换为LINQ
SQL语句如下:
select a,b,count(c) as count from table group by a,b
LINQ转换后如下:
var q =from p in db.table group p by new {p.a,p.b} into g
select new {g.key,fcount=g.count()}
select new {g.key,fcount=g.count()}
说明: g.key 代表了 a,b 两个列的返回值,fcount为重命名后的列名