title: Order a parent object by a child's property in LINQ
body: <p>How do I order by child objects in LINQ?</p>
  
  <p>Classes A, B, and C.  A has a collection of B and B has a collection of C.  I want to order object A by the Ordinal (int) property of C.</p>
  
  <pre><code>var query = from a in db.A
          orderby a.Bs.OrderBy(x=&gt; x.C.Ordinal)   &lt;--- ??
          select a;
  </code></pre>
  
  <p>I can't seem to figure out the orderby statement for this.</p>
  
  <p>EDIT:</p>
  
  <p>Sorry, my original statement was incorrect:</p>
  
  <p>A has a collection of B and B holds a C object.  C is not a collection.</p>
  
  <p>Each A should be ordered on C's ordinal property.</p>
  
  <p>ANOTHER EDIT/Solution:</p>
  
  <p>I ended up doing an .OrderBy(b=>b.C.Ordinal) on the client for each B collection in A during display. That turned out better anyway since I can let the client order by anything they need to, instead of embedding that in my repository.</p>