Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anybody please give a very simple example of "Left Outer Join" and "Right Outer Join" in lambda expression? Please give examples
Posted
Updated 16-Feb-14 18:50pm
v2

1 solution

Left outer join

XML
var emp = (from ein dbContext.Employees 
          join d in dbContext.Departmentson e.DepartmentID equals d.ID into ej
          from d in ej.DefaultIfEmpty()
          select new {e.Name, e.Phone, Department = (d.Name) });




Right outer Join

C#
var emp = (from d in dbContext.Departments
          join e in dbContext.Employees on d.ID equals e.DepartmentID into ej
          from e in ej.DefaultIfEmpty()
          select new {e.Name, e.Phone, Department = (d.Name) });
 
Share this answer
 
Comments
somnath roy24 17-Feb-14 0:49am    
Thanks pjeet_4411 but it is linq equivalent of left outer join and right outer join I need the lambda expression equivalent.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900