Sql语句实现的代码:

select goodsno, goodsspec,SUM([count]) as count  from goods 
group  by  goodsno ,goodsspec

下面这个则是用Linq实现的代码:

var res = (from l in picModel
                           group l by new { goodsno = l.GoodsNO, goodsSpec = l.SpecName, RecID = l.RecID, Position = l.Position } into g
                           select new { goodsno = g.Key.goodsno, goodsSpec = g.Key.goodsSpec, count = g.Sum(c => c.Count), RecID = g.Key.RecID, Position = g.Key.Position }).ToList();