我有一个简单的SQL查询,我正在尝试将其转换为linq。但我一直在
“......不支持”
查询是:
SELECT HARDWARE_ID, HWName, HWTyp_FK from T_HARDWARE
left join T_SWInstalled on T_HARDWARE.HARDWARE_ID = T_SWInstalled.SIHardware_FK
and SISWVerzeichnis_FK = 213
where SWInstalled_id is null
我尝试使用linq:
var cni = from hardware in _context.T_HARDWARE
where hardware.T_SWInstalled.Where(si => si.SISWVerzeichnis_FK == _softwareId) == null
select new InstalledOnListItem(hardware.HARDWARE_ID, hardware.HWName);
这实际上只适用于原始SQL吗?感谢
答案 0 :(得分:0)
使用连接语法:
var query =
from hardware in _context.T_HARDWARE
join sw in _context.T_SWInstalled
on new {
JoinProperty1 = hardware.HARDWARE_ID,
JoinProperty2 = sw.SISWVerzeichnis_FK
}
equals
new {
JoinProperty1 = sw.SIHardware_FK,
JoinProperty2 = 213
}
where sw.SWInstalled_id == null
select new InstalledOnListItem(hardware.HARDWARE_ID, hardware.HWName);