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?
???????????????????????? };
?
右連接:
var RightJoin = from dept in ListOfDepartment
join employee in ListOfEmployees on dept.ID equals employee.DeptID into joinDeptEmp
from employee in joinDeptEmp.DefaultIfEmpty()
select new?
?????????????????????????? {
EmployeeName = employee != null ? employee.Name : null,
DepartmentName = dept.Name
????????????? };
轉(zhuǎn)載于:https://www.cnblogs.com/cllchaoblog/p/4328683.html
總結(jié)
以上是生活随笔為你收集整理的Linq 实现左连接,右连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为了IT人的荣耀,请大力支持《中国人的紧
- 下一篇: attr和prop区别