我有一个层次结构,其中部门包含团队,团队包含代表。我的目标是获取属于给定部门的代表列表。我尝试使用以下方式实现:
var teams = from tms in db.Teams
where tms.DepartmentID == DepartmentID
select tms;
var TeamDelegates = from tds in db.J_TeamDelegates
where tds.TeamID in teams.TeamID //error here
select tds;
但是团队集合不允许您像访问集合一样引用特定属性。我的意思是“选择所有在团队集合中具有TeamIDs的代表。”
SelectMany
调用)更加简单明了。 - Timothy Shields