How to arrange child objects in LINQ?
Classes A, B, and C. A has set B and B has set C. I want to order object A by the Ordinal (int) property for C.
var query = from a in db.A
orderby a.Bs.OrderBy(x=> x.C.Ordinal) <--- ??
select a;
It seems like I cannot define an orderby statement for this.
EDIT:
Sorry, my original expression was incorrect:
A has a collection of B and B containing an object C. C is not a collection.
Each A must be ordered by the property of the C-ordinal.
OTHER CHANGE / Decision:
I ended up working with .OrderBy (b => bCOrdinal) on the client for each collection B in during display. It worked out anyway, since I can let the client order everything they need, instead of embedding it in my repository.
source
share