我正在尝试将此SQL查询转换为LINQ,但是我能得到的最多是联接表。之后,我无法弄清楚WHERE部分的语法或如何将其作为列表返回(ToList())。
var groups = db.ENG_Hazmanifest.SqlQuery("SELECT ENG_Hazmanifest.*,
ENG_Locations.sitenumb FROM ENG_Hazmanifest INNER JOIN ENG_Locations ON
ENG_Hazmanifest.site = ENG_Locations.id WHERE ENG_Hazmanifest.display = '1'
ORDER BY ENG_Hazmanifest.pudate").ToList();
据我所知是:
var groups = from ENG_Hazmanifest in db.ENG_Hazmanifest
join ENG_Locations in db.ENGI_Locations
on ENG_Hazmanifest.site equals ENG_Locations.id
我需要添加什么?
答案 0 :(得分:1)
想通了。
var groups = from ENG_Hazmanifest in db.ENG_Hazmanifest
where ENG_Hazmanifest.display == '1'
join ENG_Locations in db.ENGI_Locations
on ENG_Hazmanifest.site equals ENG_Locations.id select ENG_Hazmanifest;