title: Entity Framework (.NET Full Framework) Ordering Includes
body: <p>I am trying to get something like the following to work:</p>
  
  <pre><code>_dbmsParentSections = FactoryTools.Factory.PdfSections
                          .Include(x =&gt; x.Children.OrderBy(y =&gt; y.Order).ToList())
                          .Include(x =&gt; x.Hint).Include(x =&gt; x.Fields)
                          .Where(x =&gt; x.FormId == FormId &amp;&amp; x.Parent == null)
                          .OrderBy(o =&gt; o.Order)
                          .ToList();
  </code></pre>
  
  <p>The part that causes the exception is:</p>
  
  <pre><code>.Include(x =&gt; x.Children.OrderBy(y =&gt; y.Order).ToList())
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Upon further observation,</p>
  
  <pre><code>_dbmsParentSections.ForEach(x =&gt; x.Children = x.Children.OrderBy(y =&gt; y.Order).ToList());
  </code></pre>
  
  <p>did the job for me (after the initial <code>Factory</code> call and without the <code>Children.OrderBy</code>).</p>