【发布时间】:2017-02-20 13:15:11
【问题描述】:
我正在使用带有以下 SQL 表的实体框架
表TestParentChilds:
id name parent
------------------
1 John null
2 Bill 1
3 Jane 2
4 Bob 2
id 是主键,parent 是外键 - 表具有自引用。我在 EF 中有两个导航属性,称为 [Subordinates](多重性 *Many)和 [Manager](多重性 1 或 0)
我使用下面的 lambda 表达式得到了奇怪的结果
/ * DAL code */
ManagePlayEntities ctx = new ManagePlayEntities();
return ctx.TestParentChilds.ToArray()
我需要 lambda 表达式的帮助才能返回分层数据。
【问题讨论】:
-
你能澄清“奇怪的结果”吗?
标签: asp.net-mvc entity-framework linq lambda hierarchical-data