【发布时间】:2012-03-06 23:04:38
【问题描述】:
假设我有一个与自身有关系的表,例如
Table Page
-------------
IDPage
description
IDPage_FK <-- foreign key
现在这个表被实体框架映射成这样了
Class Page
-----------
int IDPage
string description
int IDPage_FK
Page Page1
IColletion<Page> Page2
如果可能的话,我想要存档的内容,它创建了一个 linq 表达式来导航所有表,并在字符串变量中生成这样的输出:
假设这个值在表中
IDPage Description IDPage_FK
1 Example null
2 Example2 1
3 Example3 2
字符串变量的输出
string inheritance = (from P in Page Select....)
输出会是这样的
Example > Example2 > Example3
有可能吗?还是我必须创建一个方法来循环到每个元素并创建变量?
【问题讨论】:
标签: c# linq entity-framework