linq - OrderBy Parent object by Nested Collection -


simple

public class timeline {   public string name {get;set}   public list<milestone> milesstones {get;set} }  public class milestone {   public string name {get;set}   public datetime time {get;set} } 

i tried: from t in dataaccess.timelinecollection.orderby(c=>c.milesstones.orderby(z=>z.milestonedate)) select t; got error "at least 1 object must implement icomparable."

i need order timeline milestone.time. first project in list 1 has eraliest time property in milestone collection.

need link.

it sounds might want

var query = dataaccess.timelinecollection                       .orderby(t => t.milestones.min(m => m.time)); 

in other words, each timeline, find earliest milestone, , use ordering.

of course if milestones in order, use:

var query = dataaccess.timelinecollection                       .orderby(t => t.milestones.first().time); 

both of these fail if timeline has no milestones.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -