I have the following dynamic list
Crew NameSurname Period Result ABC John DOE Q1 54,09 ABC John DOE Q2 59,57 ABC John DOE Q3 62,11
How to get this result in linq.
Crew NameSurname Q1 Q2 Q3 ABC John DOE 47,51 47,51 51,46
I tried this way, but I could not get the result
List.GroupBy(c => c.PersonnelID) .Select(g => new { PersonnelID = g.Key, Period1 = g.Where(c => c.Period == 1).Sum(c => c.Result), Period2 = g.Where(c => c.Period == 2).Sum(c => c.Result), Period3 = g.Where(c => c.Period == 3).Sum(c => c.Result) });
list c # linq pivot
Onuralp
source share