Linq 左连接

左连接:

var LeftJoin = from emp in ListOfEmployees 
           join dept in ListOfDepartment on emp.DeptID equals dept.ID
               into JoinedEmpDept 
               from dept in JoinedEmpDept.DefaultIfEmpty() 
               select new  
               { 
                     EmployeeName = emp.Name, 
                     DepartmentName = dept != null ? dept.Name : null  
               };

 

posted @ 2017-12-17 11:40  听雨的人  阅读(653)  评论(0编辑  收藏  举报