right outer join in linq sql

Solutions on MaxInterview for right outer join in linq sql by the best coders in the world

showing results for - "right outer join in linq sql"
Louka
27 Oct 2018
1using (JoinEntities Context = new JoinEntities())  
2{  
3    var rightOuterJoin = from d in Context.DepartmentMasters  
4    join e in Context.EmployeeMasters on d.DepartmentId equals e.DepartmentId into emp  
5    from employee in emp.DefaultIfEmpty()  
6    select new  
7    {  
8        EmployeeCode = employee.Code,  
9        EmployeeName = employee.Name,  
10        DepartmentName = d.Name  
11    };  
12    Console.WriteLine("Employee Code\tEmployee Name\tDepartment Name");  
13    foreach (var data in rightOuterJoin)  
14    {  
15        Console.WriteLine(data.EmployeeCode + "\t\t" + data.EmployeeName + "\t" + data.DepartmentName);  
16    }  
17}