title: Conditional Group By and Select using Linq (NHibernate)
body: <p>I have that query :</p>
  
  <pre><code>var group = query.GroupBy(x =&gt; new
  {
     ...
     TestName =  isSelected ? x.ClassA.Name : "" 
  });
  
  var select = group.Select(y =&gt; new MyResultDTO()
  {
     ...
     TestName = isSelected ? y.First().ClassA.Name : ""  
  });
  </code></pre>
  
  <p>That is not woriking ... I got an error :</p>
  
  <p><strong>Column 'tblClassA.Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.</strong></p>
  
  <p>But if I change my groupBy to only (take of condicional clause):</p>
  
  <pre><code>TestName = x.ClassA.Name 
  </code></pre>
  
  <p>It works fine...
  Any idea how can I do that condicional GroupBy/Select ?</p>
  
  <p>I´m using NHibernate 3.3.1</p>
  
  <p>Paul</p>