我有这个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语句。请给我任何指示,谢谢。
答案 0 :(得分: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;