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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.