0

我有这个 SQL 查询来获取所有没有分配给指定警车的警察姓名

SELECT policename 
FROM police 
LEFT OUTER JOIN policecar
ON police.policeid = policecar.policeid
AND carid = 1
WHERE policecar.policeid IS NULL

我想将该查询转换为 LINQ,但我很难转换 AND 和 WHERE 语句。请给我任何方向,谢谢。

4

1 回答 1

0

尝试这个:

var result =
    from police in polices
    join policecar in policecars.Where(x => x.carid == 1)
            on police.policeId equals policecar.policeId into res
    where !res.Any()
    select police.policeName;
于 2013-10-03T03:04:30.343 回答