Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个内部A集合的实体B。我用一个_entity.A.Include(a => a.B)
A
B
_entity.A.Include(a => a.B)
现在我想让 B 到 A 中按自定义 OrderBy 排序。我试过_entity.A.Include(a => a.B.OrderBy(o => o.Version)了,但我得到了:
_entity.A.Include(a => a.B.OrderBy(o => o.Version)
包含路径表达式必须引用在类型上定义的导航属性。对引用导航属性使用虚线路径,对集合导航属性使用 Select 运算符。
关于如何做到这一点的任何想法?
谢谢。
版本是一个整数。
I think in this case you can try:
var list = _entity.A.Include("B").ToList(); list.ForEach(m => m.B = m.B.OrderBy(o => o.Version));
or:
_entity.A.Include("B").Select(m => new A { //some props, B = m.B.OrderBy(o => o.Version) });