Mid LINQ

Get total salary by department?

Get total salary by department

var totalByDept = employees

.GroupBy(e => e.Department)

.Select(g => new {

Department = g.Key,

Total = g.Sum(e => e.Salary)

});

More from LINQ Tutorial

All questions for this course