linq to sql recursive query

后端 未结 4 448
感情败类
感情败类 2020-12-06 05:12
EmployeeId  Name  ManagerId
------------------------------
1           A     null
2           B     null
3           C     1
4           D     3
5           E     2
         


        
4条回答
  •  有刺的猬
    2020-12-06 05:52

    var managedEmployees = ctx.Employess.Where(x => x.ManagerId = 4).AsEnumerable()
    

    If you want the whole tree at once, the solution is more complex. In SQL its best done with an CTE, I don't know if EF can handle this using linq- more likely an iterative solution would be used.

提交回复
热议问题