【发布时间】:2013-03-13 06:02:16
【问题描述】:
我正在尝试使以下内容起作用:
_dbmsParentSections = FactoryTools.Factory.PdfSections
.Include(x => x.Children.OrderBy(y => y.Order).ToList())
.Include(x => x.Hint).Include(x => x.Fields)
.Where(x => x.FormId == FormId && x.Parent == null)
.OrderBy(o => o.Order)
.ToList();
导致异常的部分是:
.Include(x => x.Children.OrderBy(y => y.Order).ToList())
编辑:
进一步观察,
_dbmsParentSections.ForEach(x => x.Children = x.Children.OrderBy(y => y.Order).ToList());
为我完成了这项工作(在最初的 Factory 呼叫之后并且没有 Children.OrderBy)。
【问题讨论】:
-
感谢您提供的答案也对我有用
-
.Include(x => x.Children.OrderBy(y => y.Order)) 适合我!
标签: c# linq entity-framework entity-framework-5