I have these tables
public class TaskDetails { public string EmployeeName {get; set;} public decimal EmployeeHours {get; set;} } public class Tasks { public string TaskName {get; set;} public List<TaskDetails> TaskList {get; set;} } I have a function that returns a List<Tasks>. What I would need is to create a new List that groups the EmployeeNames and SUM the EmployeeHours irrespective of the TaskName. That is, I need to fetch TotalHours of each Employees. How to get that?
P.S: And to what have I done so far. I have stared at the code for a long time. Tried Rubber Duck Problem solving to no avail. I can do get the results using a foreach and placing it to a Dictionary<string, decimal>. That logic will be to check if key does not exist, add a new key and assign the value and if the key exists add the decimal value to the original value. But I feel its too much here. I feel there is a ForEach - GroupBy - Sum combination which I am missing.
Any pointers on how to do it will be very helpful for me.
'Tasks': member names cannot be the same as their enclosing type. You can't have aTasksproperty on theTasksclass.