Mid LINQ

How to perform a left outer join in LINQ?

How to perform a left outer join in LINQ?

var leftJoin = from d in departments

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

into empGroup

from emp in empGroup.DefaultIfEmpty()

select new { Department = d.Name, EmployeeName =

emp?.Name ?? "No Employee" };

Explanation:

Returns all departments with matching employees or “No Employee” if none exist.

More from LINQ Tutorial

All questions for this course