Left Join using LINQ
Using LINQ, Left Join can be acheived as follows
var LeftJoin = from emp in ListOfEmployees join dept in ListOfDepartment on emp.DeptID equals dept.ID into JoinedEmpDept from dept in JoinedEmpDept.DefaultIfEmpty() select new { EmployeeName = emp.Name, DepartmentName = dept != null ? dept.Name : null };
I always have to lookup how to do a left join with Linq, so this is my little code snippet reblog so I can always find it
Posted via email from wiibart.com | Comment »