3
我有兩個表「員工」和「EmployeesCompanies」,員工包含了所有員工的列表,並employeescompanies包含與員工相關的所有公司的名單:LINQ到SQL左外連接不
Table 1 (Employees) EmployeeID 1 2 3 Table 2 (EmployeesCompanies) EmployeeID 1 2
我想回到 3是從EmployeesCompanies缺少的記錄,這裏是我使用的LINQ代碼:
var queryOrphanedEmployees = (from a in db.Employees
join b in db.EmployeesCompanies
on a.EmployeeID equals b.EmployeeID
into outer
from c in outer.DefaultIfEmpty()
select new { a.EmployeeID}).ToList();
然而,這將返回:
1 2
這與我想要的完全相反。