日期:2014-05-20 浏览次数:21013 次
左连接: 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 };
------解决方案--------------------
六楼 q107770540 正解
------解决方案--------------------
linq to sql 没有什么 右连接吧!
两个表的顺序换一下,效果是有了, 还是左连接啊