title: Using Entity Framework dynamically sort by a column in a child
body: <p>I call dynamically sort rows of a table when the orderby column is in the parent table doing the following...
  </p>
  
  <pre><code>public List&lt;ServiceRequest&gt; SortSRsByParentFields(string p_Criteria, 
                                                    bool p_sortDescending,
                                                    bool p_ShowAll = true) {
  
      var propertyInfo = typeof(ServiceRequest).GetProperty(p_Criteria);
      var sortedList1 = new List&lt;ServiceRequest&gt;();
      var sortedList2 = new List&lt;ServiceRequest&gt;();
  
      var myServiceRequests = GetMyServiceRequests();
      var otherServiceRequests = GetOthersServiceRequests();
  
      if (p_sortDescending)
      {
        sortedList1 = myServiceRequests
          .AsEnumerable()
          .OrderByDescending(x =&gt; propertyInfo.GetValue(x, null)).ToList();
  
        sortedList2 = otherServiceRequests.AsEnumerable()
          .OrderByDescending(x =&gt; propertyInfo.GetValue(x, null))
          .ThenBy(x =&gt; x.Client.LastNameFirst).ToList();
      }
      else
      {
        sortedList1 = myServiceRequests.AsEnumerable()
           .OrderBy(x =&gt; propertyInfo.GetValue(x, null)).ToList();
        sortedList2 = otherServiceRequests.AsEnumerable()
           .OrderBy(x =&gt; propertyInfo.GetValue(x, null))
           .ThenBy(x =&gt; x.Client.LastNameFirst).ToList();
      }
  
      var allSRs = p_ShowAll == false ? sortedList1.Concat(sortedList2).Take(1000)
          .ToList() : sortedList1.Concat(sortedList2).ToList();
      return allSRs;
    }
  </code></pre>
  
  <p>But I can't seem to make this method work if the orderby column is in a child table (a table related to the parent though an FKey).  </p>
  
  <p>So the question is how do I make that work? </p>