我有如下表。我需要为提供的用户 ID 获取所有经理 ID。
userid managerid
10     1
9      10
6      9
2      6
4      1
如果我将 2 传递给我的方法,我需要得到 1、10、9 和 6。我编写了以下查询,它将仅返回第一级父级。即它只会返回 6 和 9。
public List<int?> mymethod (int userId){
return (from e in mycontext.EmployeeManagers
                     join e1 in m_context.EmployeeManagers
                        on e.UserId equals e1.ManagerId
                    where e1.UserId == userId
                     select e1.ManagerId).AsQueryable().ToList()
}
如何修改查询以返回所有经理雇佣关系?
请帮忙。