title: How to order child collections of entities in EF
body: <p>I have the following query:</p>
  
  <pre><code>public IEnumerable&lt;Team&gt; GetAllTeamsWithMembers(int ownerUserId)
          {
              return _ctx.Teams
                   .Include(x =&gt; x.TeamMembers)
                   .Where(x =&gt; x.UserId == ownerUserId)
                   .OrderBy(x =&gt; x.Name).ToList();
  
          }
  </code></pre>
  
  <p>How do I go about ordering the teams by their name, and then have all the child members of each team sorted by their name?</p>
  
  <p>It seems that do this I need to create a new DTO class and use a select. I'd like to use the EF entities already created, in this case Team has a navigation property to Members. I return <code>IEnumerable&lt;Team&gt;</code> out from my repository layer. </p>
  
  <p>There doesn't seem to be a neat way of ordering child collections in EF. Can anyone help?</p>