title: nHibernate group by year and month with count
body: <p>I am trying to get a list of all Years and Months for a set of articles/blogs. </p>
  
  <pre><code>var query = (from article in _session.Query&lt;Article&gt;()
              where article.Parent == articleList &amp;&amp; article.PublishOn != null
              group article by new {article.PublishOn.Value.Year, article.PublishOn.Value.Month}
              into entryGroup
              orderby entryGroup.Key.Year descending, entryGroup.Key.Month descending
              select new ArchiveModel
              {
                  Year = entryGroup.Key.Year,
                  Month = entryGroup.Key.Month,
                  Count = entryGroup.Count()
              });
  
  
  return query.ToList();
  </code></pre>
  
  <p>The above compiles but nHibernate throws:</p>
  
  <pre><code>System.NotSupportedException {"NewExpression"}
  </code></pre>
  
  <p>Is there a way I can create this query using any of the other query methods in nHibernate? </p>
  
  <p>I did manage to get it working using SQL Projects and using YEAR(date) but then this didn't run in SQLlite. I need it to be database agnostic if possible.</p>