大家好,我在数据表中的数据如下
SKU Quantity UnitPrice LinePrice
A 10 2 20
A 10 2 20
B 10 2 40
我想总结一下有重复记录的SKU,得到的结果如下
SKU Quantity UnitPrice LinePrice
A 20 2 40
B 10 2 40
我试过这个但没有运气
var query = from row in lDTSalesOrder.AsEnumerable()
group row by row.Field<string>("SKU") into grp
orderby grp.Key
select new
{
Id = grp.Key,
Sum = grp.Sum(r => r.Field<double>("UnitPrice"))
};