Group By records , Sum of records using LINQ
int cityTotals = cities
.GroupBy(c => c.City)
.Select(grp => new { City = grp.Key, Total = grp.Sum(c => c.Total) })
.Where(c => c.Total > 20)
.Sum(c => c.Total);
int cityTotals = cities
.GroupBy(c => c.City)
.Select(grp => new { City = grp.Key, Total = grp.Sum(c => c.Total) })
.Where(c => c.Total > 20)
.Sum(c => c.Total);
Comments
Post a Comment