In the above query we can see that first we join Employees and department on Department ID and the output of that join is joined with branch on brachid. By following the same flow we can derive the same result using LINQ. The equivalent implementation in LINQ follows

11 Responses to “Multiple List Left Join in LINQ”

bramoinsaid

Hi,
In your example for left join with multiple lists, it is easy when the class has a one or two members but if the class is large, how do you specify the whole thing rather than writing each one out. I am referring to the line below in the code segment that begins with <<<. (See below)

manojsaid

Hi,
I am new to linq,Pls help me on the below sql query into Linq.My requirement is to retrieve all the records from the session table if either subjectid or testid can be null
I tried with the linq ,but the output is not retreiving all the records from the session table for the passing student id.
Thanks in advance

SQL:
select su.subjectid,su.subjectname,t.testid,t.testname,p.personname
from session as se inner join tutor as tu on se.tutorid=tu.tutorid inner join person as p on tu.personid = p.personid left join subjects as su on se.subjectid = su.subjectid left join test as t on se.testid =t.testid where se.studentid =selectedStudID

Shalu davidsaid

manojsaid

Hi,
I am new to linq,Pls help me on the below sql query into Linq.My requirement is to retrieve all the records from the session table if either subjectid or testid can be null
I tried with the linq ,but the output is not retreiving all the records from the session table for the passing student id.
Thanks in advance

SQL:
select su.subjectid,su.subjectname,t.testid,t.testname,p.personname
from session as se inner join tutor as tu on se.tutorid=tu.tutorid inner join person as p on tu.personid = p.personid left join subjects as su on se.subjectid = su.subjectid left join test as t on se.testid =t.testid where se.studentid =selectedStudID