Reputation: 25
var query = from section in load_sections.Sections
join course in load_sections.Courses
on section.Course_Id equals course.Course_Id
join faculty in load_sections.Faculties
on section.Faculty_Id equals faculty.Faculty_Id
select section;
I have some null values in my section.Faculty_Id which will not be equal to any row in faculty.Faculty_Id and it is just returning the records where section.Faculty_Id is not null...If section.Faculty_Id is not null, then it must return the other remaining fields of Table Courses
Upvotes: 0
Views: 324
Reputation: 109255
If you can't drop the join on faculty
for whatever reason, you'll have to construct an outer join:
var query = from section in load_sections.Sections
join course in load_sections.Courses
on section.Course_Id equals course.Course_Id
join faculty in load_sections.Faculties
on section.Faculty_Id equals faculty.Faculty_Id into faculties
from f in faculties.DefaultIfEmpty()
select section;
This executes a GroupJoin
with Faculties
. The effect of the subsequent from f in faculties
is that the grouping is flattened again by a SelectMany
. .DefaultIfEmpty()
creates the outer join.
Upvotes: 2