static void Example7() { List <MonthlySales> result = MonthlySales.GetMonthlySales() .SelectMany(x => x.Sales, (MonthlySalesObj, SalesObj) => new { MonthlySalesObj.Month, SalesObj } ).GroupBy(x => new { x.Month, ProductName = x.SalesObj.Key }) .Select(x => new MonthlySales { Month = x.Key.Month, Sales = new Dictionary <string, double> { { x.Key.ProductName, x.Sum(z => z.SalesObj.Value) } } }).ToList(); }
static void Example8() { var result = MonthlySales.GetMonthlySales().SelectMany((x, i) => x.Sales.Select(z => z.Value + i)); }