title: NHibernate, get rowcount when criteria have a group by
body: <p>I need to get the count of rows from a criteria query and the criteria got group by projections. (needed to get paging to work)</p>
  
  <p>E.g. </p>
  
  <pre><code>projectionList.Add(Projections.GroupProperty("Col1"), "col1")
                .Add(Projections.CountDistinct("Col2"), "Count");
  </code></pre>
  
  <p>I need to avoid CreateSQL, since I have a lot of criteria.. and the restrictions etc are complex.</p>
  
  <p>Can you do a subcriteria (detached) and then <code>select count(*) from ..</code> ? Can't figure out how?</p>
  
  <p>EDIT: I solved it by getting the sql from the criteria and then modifying it so that it now works! <a href="https://stackoverflow.com/questions/7957184/catching-the-nhibernate-generated-sql-and-amending-before-running">GetSql from criteria</a></p>