我看过其他几个帖子问类似的问题,但坦率地说我很困惑。我正在尝试在 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
andUNION
子句。
from t in LmsTeams
join g in Games on t.GameId equals g.Id
where t.GameId == 1 && t.Active == true
select t