title: Order by relation count in NHibernate
body: <p>I have a datastructure like this:</p>
  
  <pre><code>public class User
  {
      public Guid Id {get;set;}
      public string Name {get;set;}
      public IList&lt;Books&gt; Books {get;set}
  }
  </code></pre>
  
  <p>I have been struggeling with making it possible to sort the users by the count of bookmarks (one-to-many relation). </p>
  
  <p>I have tried various approaches with both linq, criteria and queryover, but with no luck, and therefore hope one of you could help.</p>
  
  <p>I am using paging, since I have quite a few users, so the solution needs to do the query on the SQL and not in memory on the webserver.</p>