标签:count lin int from compare 求和 esc lis des
var data = (from a in Items group a by new { a.GroupId, a.Id } into b orderby new ComparerItem() { GroupId = b.Key.GroupId, Id = b.Key.Id } descending select new { GroupId = b.Key.GroupId, Id = b.Key.Id, Count = b.Sum(c => c.Count), Weight = b.Sum(c => c.Weight) }).OrderBy(t => t.GroupId).ThenBy(t => t.Id);
items 是一个包含4个字段(GroupId, Id, Count, Weight)的list.
效果,按GroupId,Id 分组 ,并统计Count字段和Weight字段
标签:count lin int from compare 求和 esc lis des
原文地址:http://www.cnblogs.com/sxypeace/p/6677424.html