title: Ordering parent's list of children
body: <p>As part of an MVC app I have two classes which map to the appropriate tables in my database</p>
  
  <pre><code>public class Child {
      public int id;
      public int parentId; //foreign key to parent class
      public int age;
  }
  
  public class Parent {
      public int id; 
      public virtual IList&lt;Child&gt; children;
  }
  </code></pre>
  
  <p>In my controller I need to select only one parent by the id, including its list of children.</p>
  
  <p>With the parent that gets selected, I want that parent's list of children to be in order of age.
  I have been able to do this with the following code:</p>
  
  <pre><code>Parent parent = context.parents.FirstOrDefault(p =&gt; p.id == idToCheck);
  parent.children = parent.children.OrderBy(c =&gt; c.age).Cast&lt;Child&gt;().ToList();
  </code></pre>
  
  <p>Even though this works, I am left with the feeling that this is a hackish way to do what I'm after.</p>
  
  <p>From what I've read, it is not possible to order children when I initially select the parent. Is that correct?</p>
  
  <p>Is there anything I am doing in the above code that could/should be done better?</p>