I want to group by the WorkGroup.GroupId property on the class
public class Employee
{
public int EmployeeID {get; set;}
public Group WorkGroup {get; set;}
}
However I need to output the group name property (Which could have duplicates but will be identical between the same groupid)
Something like (this of course does not work):
var grps = from emp in Emps
group emp by emp.WorkGroup.GroupID into g
select new { GroupID = g.Key, Title = g.Key.WorkGroup.GroupTitle, Employees = g };
I am looking for output that would allow me to do:
foreach (var g in grps)
{
Console.WriteLine(g.Title + "-" + g.GroupID);
foreach (var e in g.Employees)
{
Console.WriteLine(e.EmployeeID);
}
}