我有一个实体A,里面有B的集合.我用_entity.A.Include(a => a.B)加载它们
现在我希望将B放入A中,按自定义OrderBy排序.我试过_entity.A.Include(a => a.B.OrderBy(o => o.Version)但我得到了:
The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.
有关如何实现这一目标的任何想法?
谢谢.
版本是整数.
解决方法
我想在这种情况下你可以尝试:
var list = _entity.A.Include("B").ToList(); list.ForEach(m => m.B = m.B.OrderBy(o => o.Version));
要么:
_entity.A.Include("B").Select(m => new A { //some props,B = m.B.OrderBy(o => o.Version) });