LINQ

1. Group By Multiple Elements 1

xxx.GroupBy(x => new { x.A, x.B });

2. Group By Multiple Elements 2

var result = (from t in Items
              group t by new {t.A, t.B}
              into g select new
                     {
                        g.Key.A,
                        g.Key.B,
                        Quantity = g.Sum(t => t.Quantity)
                      }).ToList();

3. Order By Multiple Elements.
DO NOT use .OrderBy(xxx).OrderBy(yyy). This will result in ONLY ordering the list by “yyy”

var result = items.OrderBy(x => x.A).ThenBy(x => x.B)