title: nHibernate QueryOver Having clause with OR condition
body: <p>How to achieve the below query in nHibernate using queryover</p>
  
  <h2>Query</h2>
  
  <pre><code>SELECT [DepartmentID]  ,COUNT(courseId)
  FROM  [Course]
  where [DepartmentID] &gt;1
  GROUP BY [DepartmentID]
  hAVING COUNT(courseId) = 2 or  COUNT(courseId) = 3;
  </code></pre>
  
  <hr>
  
  <p>Table structure</p>
  
  <pre><code>    CREATE TABLE [dbo].[Course](
  [CourseID] [int] NOT NULL,
  [Title] [nvarchar](100) NOT NULL,
  [Credits] [int] NOT NULL,
  [DepartmentID] [int] NOT NULL,
  </code></pre>
  
  <hr>
  
  <p>C# code i tried</p>
  
  <pre><code>Collection&lt;Course&gt; courseList = new Collection&lt;Course&gt;();
  using (var session = NHibernateHelper.OpenSession("ConnectionName1"))
  {
     Course courseAlias = null;
     SimpleExpression e1 = Restrictions.Ge(Projections.Count(Projections.Property(() =&gt; courseAlias.CourseID)), 2);
     SimpleExpression e2 = Restrictions.Ge(Projections.Count(Projections.Property(() =&gt; courseAlias.CourseID)), 3);
     var results2 = session.QueryOver&lt;Course&gt;(() =&gt; courseAlias)
                    .Where(e1||e2)
                    .SelectList(list =&gt; list
              .SelectGroup(x =&gt; x.DepartmentID).WithAlias(() =&gt; courseAlias.DepartmentID)
              .SelectCount(x =&gt; x.CourseID).WithAlias(() =&gt; courseAlias.CourseID)
               ).TransformUsing(Transformers.AliasToBean&lt;Course&gt;()).List&lt;Course&gt;();
  }
  </code></pre>