如何在LINQ中编写此查询:
SELECT Name,
READY = max(CASE TrDet.tracktypeid WHEN 7 THEN 1 END),
AVAILABLE = max(CASE TrDet.tracktypeid WHEN 2 THEN 1 WHEN 5 THEN 1 END)
FROM PENDINGAPPROVAL Apr
JOIN TRACKS Tr ON Apr.TrackId = Tr.Id
JOIN TRACK_DETAIL TrDet ON Tr.Id = TrDet.TrackId
GROUP BY Tr.Name
由于
答案 0 :(得分:1)
这并没有回答你提出的问题,但这可以得到你想要的答案:
var results=context.PENDINGAPPROVAL.Select(p=>new {
Name=p.Name,
READY=p.Tracks.Any(t=>t.TRACK_DETAILS.Any(td=>td.tracktypeid==7))
AVAILABLE=p.Tracks.Any(t=>t.TRACK_DETAILS.Any(td=>td.tracktype==2 || td.tracktype==5))
});