按多列分组如何在LINQ中实现GroupBy多列类似于SQL中的内容:SELECT * FROM <TableName> GROUP BY <Column1>,<Column2>如何将其转换为LINQ:QuantityBreakdown(
MaterialID int,
ProductID int,
Quantity float)INSERT INTO @QuantityBreakdown (MaterialID, ProductID, Quantity)SELECT MaterialID,
ProductID, SUM(Quantity)FROM @TransactionsGROUP BY MaterialID, ProductID
3 回答
尚方宝剑之说
TA贡献1788条经验 获得超4个赞
var query = (from t in Transactions group t by new {t.MaterialID, t.ProductID} into grp select new { grp.Key.MaterialID, grp.Key.ProductID, Quantity = grp.Sum(t => t.Quantity) }).ToList();
- 3 回答
- 0 关注
- 413 浏览
添加回答
举报
0/150
提交
取消