Click here to Skip to main content
14,391,880 members
Rate this:
Please Sign up or sign in to vote.
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 19:50pm
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Left outer join

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

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) });
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100