I have the follow List(InputData), and I would like to group by Vendor then by Type and Summarize by NumberInvoice and Concatenate by Month
CodePudding user response:
This will work
var result = InputData
.OrderBy(x => x.Month)
.GroupBy(x => x.Month)
.SelectMany(x => x.GroupBy(y => new {y.Vendor, y.Type, y.NumberInvoice})
.Select(y => new { Vendor = y.Key.Vendor, Type = y.Key.Type, month = x.Key, numberInvoices = y.Count()}).ToList()).ToList();