title: SQL to NHibernate Criteria Query
body: <p>I'm using Sharp Architecture for an MVC application and I'm trying to generate a nhibernate criterion query for the following SQL:</p>
  
  <pre><code>select top 10 p.* from Tab1 p 
                  join Tab2 v on p.Id = v.Tab1Fk
                  join Tab3 sbu on v.Id = sbu.Tab2Fk
                  where sbu.DateTime &gt;= 12/12/2002 00:00:00
                  group by p.Id, p.Name, p.CoCode, p.CuCode, p.StCode, p.ParentFk, p.LastGenerated
                  order by COUNT(sbu.Id) desc
  </code></pre>
  
  <p>Currently I've got:</p>
  
  <pre><code>var crit = Session.CreateCriteria&lt;Tab1&gt;();
          crit.SetMaxResults(numberOfRecords);
          crit.CreateCriteria("Tab2", "v", JoinType.InnerJoin)
              .CreateCriteria("Tab3", "sbu", JoinType.InnerJoin)
              .Add(Restrictions.Ge("sbu.DateTime", since))
              .AddOrder(Order.Desc(Projections.Count("sbu.Id")));
          return crit.List&lt;Tab1&gt;();
  </code></pre>
  
  <p>But it throws errors, can anyone help?</p>