我见过
Ordering sub-items within ordered items in a Linq to Entities Query
这意味着没有办法让存储库以特定的顺序返回实体图中的子项。
如果是这样的话,有没有想过如何在一个编辑中为这些项目排序?
即
//This works but returns a random order
<%: Html.EditorFor(model => model.HPERDET.HORDERS) %>
//This errors with "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."
<%: Html.EditorFor(model => model.HPERDET.HORDERS.OrderBy(m=>m.APP_DATE)) %>
//presorting the HORDERS into
//a public IOrderedEnumerable<HORDER> SortedHorders { get; set; }
//and ordering in my view model works, but breaks the binding because
//the generated html inputs no longer have the correct hierarchical names
<%: Html.EditorFor(model => model.SortedHorders) %>
那么,是否有一种方法可以对图中的子实体进行排序,以便在不使用汇编POCO对象的情况下将它们与editorfor一起使用?除了顺序之外,所有的ef对象都是重复的?