陋室铭
永远也不要停下学习的脚步(大道至简至易)

这是执行前和执行后想要的效果

 

以下是用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();
posted on 2019-01-18 20:15  宏宇  阅读(2640)  评论(0编辑  收藏  举报