title: Linq OrderBy Count In linked list
body: <p>I've been struggling for a while now. All I am trying to do is OrderBy a list of records by the Count() of a 3rd child in the relationship tree. I will try and draw the 3 tables involved below, sorry if I don't use the stackoverflow standards:</p>
  
  <p>Websites ----> Roles ----> Permissions</p>
  
  <p>In words, a website can have more than 1 Roles, a role can have more than 1 Permissions. So it's a 1-to-many.</p>
  
  <p>When I try something like: </p>
  
  <pre><code>List&lt;Website&gt; websites = Model.WebsiteOptions.OrderBy( o =&gt; o.Roles.OrderBy( r =&gt; r.RolePermissions.Count ) ).ToList();
  </code></pre>
  
  <p>I get an error that's clear enough:</p>
  
  <blockquote>
    <p>At least one object must implement IComparable. </p>
  </blockquote>
  
  <p>but I still don't know how I can either way order Websites by the number of Permissions each Role has...What I want is for websites that have Roles with the most Permissions to come first.</p>
  
  <p>Please does anyone know or show me some guidance?</p>
  
  <p>Thanks in advance.</p>