1
我试图让一个人属于使用此查询的团队。问题在于它返回了人员所在团队的所有部门的团队(我得到了多个相同的记录)。我想我必须替换.contains,但我无法弄清楚,因为我是一个完整的newb,并且找不到任何有用的双连接示例。为了使其按预期工作,我必须改变什么?提前致谢。双连接查询返回多个相同的记录而不是唯一的记录
public IQueryable<Team> GetTeamsByPersonID(int id)
{
return from t in entities.Teams
join d in entities.Departments
on t.TeamID equals d.TeamID
where (from p in entities.Person_Departments
join dep in entities.Departments
on p.DepartmentID equals dep.DepartmentID
where p.PersonID == id
select dep.TeamID).Contains(d.TeamID)
select t;
}
我不知道我能写这样的....就这么简单!非常感谢! – Tsarl