Entity Framework 4 / Linq: How to OrderBy() a hierarchical Entity? -
i have viewmodel carved several entity relations:
products[].prices[].others[].myfield
how order products[] nested myfield? when clause, it's this:
products.where( p => p.prices.any( q => q.others.any( r => r.myfield == 4)));
so if wanted products.orderby() , order myfield, expression like?
products.orderby( p => p.prices.selectmany( ??
as have several prices below product need select 1 sort on, like
products.orderby( p => p.prices.first().others.first().myfield )
or if want order highest price
products.orderby( p => p.prices.orderbydescending(price => price.value).first().others.first().myfield )
Comments
Post a Comment