.Net
How to use left join in Entity Framework
Before going to the topic let see what is Left join.A Left outer join is a join in which each element of the first collection is returned, regardless of whether it has any correlated elements in the second collection. It can be performed by calling the DefaultIfEmpty() method on the results of a group join. Below is the example
var result= (from st in db.StudentMaster
join cos in db.CourseMaster on st.CourseId equals cos.CourseId into studentdet
from stu in studentdet.DefaultIfEmpty()
select new { st.StudentName,cos.CourseName} )
Below is the same code for the SQL query.
Select st.StudentName, cos.CourseName from StudentMaster st left join CourseMaster cos on st.CourseId = cos.CourseId.