我正在使用c#从sql查询中填充数据表。它有两列
env issud
Dit x
Dit x
Sit y
linq查询的输出应将env和问题计数分组Dit 2Sit 1
听起来你想要:
var query = table.GroupBy(x => x.env)
.Select(g => new { Env = g.Key, Count = g.Count() };
或者作为查询表达式:
var query = from row in table
group row by row.env into g
select new { Env = g.Key, Count = g.Count() };