Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Group #linq #multiple #columns
ADD COMMENT
Topic
Name
1+6 =