KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 can I get this result with in linq. Crew NameSurname Q1 Q2 Q3 ABC John DOE 47,51 47,51 51,46 I've tried this way but I couldn't 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) });
Tags (comma-separated)
Save Edits
Cancel