title: NHibernate Linq Query with Projection and Count error
body: <p>I have the following query:
  </p>
  
  <pre><code>var list = repositoy.Query&lt;MyClass&gt;.Select(domain =&gt; new MyDto()
  { 
      Id = domain.Id,
      StringComma = string.Join(",", domain.MyList.Select(y =&gt; y.Name))
  });
  </code></pre>
  
  <p>That works great:
  </p>
  
  <pre><code>list.ToList();
  </code></pre>
  
  <p>But if I try to get the Count I got an exception:
  </p>
  
  <pre><code>list.Count();
  </code></pre>
  
  <p>Exception</p>
  
  <pre><code>NHibernate.Hql.Ast.ANTLR.QuerySyntaxException
  
  A recognition error occurred. [.Count[MyDto](.Select[MyClass,MyDto](NHibernate.Linq.NhQueryable`1[MyClass], Quote((domain, ) =&gt; (new MyDto()domain.Iddomain.Name.Join(p1, .Select[MyListClass,System.String](domain.MyList, (y, ) =&gt; (y.Name), ), ))), ), )]
  </code></pre>
  
  <p>Any idea how to fix that without using <code>ToList</code> ?</p>