标签:rom foreach each items count() item group table core
TableA
{
Id int,
Name string,
Group int
Score int
}
从
| Id | Name | Group | Score |
|---|---|---|---|
| 1 | 张三 | A | 70 |
| 2 | 李四 | A | 80 |
| 3 | 王五 | B | 70 |
| 4 | 赵六 | B | 80 |
到
| Name | Score |
|---|---|
| A | 150 |
| 张三 | 70 |
| 李四 | 80 |
| B | 150 |
| 王五 | 70 |
| 赵六 | 80 |
var items=from x in TableA
group x by x.Group into gg
select gg;
foreach(var item in items)
{
print item.Key , item.Count();
foreach(var sItem in item.ToList())
{
print sItem.Name , sItem.Score;
}
}
标签:rom foreach each items count() item group table core
原文地址:http://www.cnblogs.com/catzhou/p/6163838.html