我看到了其他几篇类似的帖子,但老实说,我很困惑。 我正在尝试在EntityFarmework和Linq中执行以下sql语句,但无法使'NOT IN'和'UNION'正常工作。
SELECT LmsTeam.* FROM LmsTeam
INNER JOIN Game ON LmsTeam.GameId = Game.ID
WHERE LmsTeam.Id NOT IN
(SELECT TeamHomeId as TeamID FROM LmsEventMatch WHERE EventId =1
UNION
SELECT TeamAwayId as TeamID FROM LmsEventMatch WHERE EventId =1)
AND LmsTeam.GameId = 1 AND LmsTeam.Active = 1
我已经拥有下面的join
和一些where子句,但无法完成NOT IN
和UNION
子句。
from t in LmsTeams
join g in Games on t.GameId equals g.Id
where t.GameId == 1 && t.Active == true
select t