在Entity Framework中,entity.children仅返回第一个子级

|| 我在EF4中有一个模型。此模型中有两个层次实体,它们彼此之间具有0..1->许多关系(它们具有ParentId字段),因此每个实体都具有Parent(相同类型)和Children(相同类型的集合)属性。它们的定义几乎相同。 其中一个可以正常工作,但在另一个中,Children属性如果有多个孩子,则始终包含第一个孩子事件。 更新: 我使用Sql Server Profiler进行了测试:
var p = from item in context.Entity1.Include(\"Children\")
    where item.Id == 15
    select item;
var q = from unit in context.Entity2.Include(\"Children\")
    where unit.Id == 239
    select unit;
这两个Linq语句都生成返回3条记录的sql查询,因为ID为15的Entity1和ID为239的Entity2都有3个子级。 q.First()。Count返回1,但是p.First()。Count返回3。     
已邀请:

要回复问题请先登录注册