Mid LINQ

How to group join with multiple collections?

How to group join with multiple collections?

var groupJoin = from d in departments

join e in employees on d.Name equals e.Department

into empGroup

select new { Department = d.Name, Employees =

empGroup };

foreach (var group in groupJoin)

Console.WriteLine($"{group.Department}:");

foreach (var emp in group.Employees)

Console.WriteLine($" - {emp.Name}");

Follow :

Explanation:

Groups employees under their respective departments.

More from LINQ Tutorial

All questions for this course