group by multiple values linq c# code example
Example 1: Group by linq multiple columns C#
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();
Example 2: linq group by multiple
group x by new { x.Column1, x.Column2 }