title: How to order table retrieved via .Include("table") using LINQ?
body: <p>I have this LINQ code and it works well. I can order the <code>Posts</code>, but I need also to order  the <code>Comments</code> retrieved via <code>Include("Comments")</code>: <code>orderby comment.DateAndTime descending</code></p>
  
  <p>How to achieve that in LINQ code; (ordering comments)?.</p>
  
  <p>Also I am wondering if there is a way to achieve that directly in the underlying database table definition?; Comments table definition.</p>
  
  <pre><code>public IQueryable&lt;Post&gt; ListViewPosts_GetData()
  {
      FacebookDataEntities entities = new FacebookDataEntities();
  
      var friends_A = from f in entities.Friends
                      where f.Friend_B == User.Identity.Name &amp;&amp; f.AreFriends
                      select f.Friend_A;
  
      var friends_B = from f in entities.Friends
                      where f.Friend_A == User.Identity.Name &amp;&amp; f.AreFriends
                      select f.Friend_B;
  
      return from p in entities.Posts.Include("Comments")
             let userName = p.UserName
             where userName == User.Identity.Name
            || friends_A.Concat(friends_B).Contains(userName)
             orderby p.DateAndTime descending
             select p;
  }
  </code></pre>