我还在学习Entity表达式的绳索,我想将这个SQL查询实现到Entity表达式中,查询是:
SELECT classname,abbreviation, cid
FROM [db].[dbo].[classes] AS c
WHERE c.cid IN (
SELECT DISTINCT(CID)
FROM [db].[dbo].[CDS]
WHERE
sid = '1'
AND
did = '24'
)
ORDER BY abbreviation, classname
我如何将该查询实现到实体表达式?
答案 0 :(得分:0)
表达式为:
context.Classes.Where(C =>
(context.CDS.Where(CD => CD.sid == "1" && CD.did == "24")
.Distinct(CD => CD.CID)).Contains(C.CID))
.Select(C => new {
className = C.className,
abbreviation = C.abbreviation,
cid = C.cid
});
希望这会有所帮助!!