我有两张桌子:
Team: teamId, teamName
Player: playerId, teamId, playerName
我想通过 playerName 获取 teamName。我写了两个查询,其中一个不起作用。
var query = from t in dc.Teams
where t.teamId == ((from p in dc.Players
where p.playerName == "kobe"
select p.teamId).SingleOrDefault())
select t.teamName; //Doesn't work
var query = from t in dc.Teams
join p in dc.Players
on t.teamId equals p.teamId
where p.playerName == "kobe"
select t.teamName; //Works
谁能告诉我为什么第一个查询不起作用?