c#linq去除重复项并将相同数据的数量字段值相加
2021-06-19 04:06
标签:重复项 lis position rom new 分享 spec com from 这是执行前和执行后想要的效果 以下是用Sql语句实现的代码: 下面这个则是用Linq实现的代码: c#linq去除重复项并将相同数据的数量字段值相加 标签:重复项 lis position rom new 分享 spec com from 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/10289522.htmlselect goodsno, goodsspec,SUM([count]) as count from goods
group by goodsno ,goodsspec
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();
文章标题:c#linq去除重复项并将相同数据的数量字段值相加
文章链接:http://soscw.com/index.php/essay/95785.html