I wouldn't call it weird. You have a "client side" projection (not a
subselect), which can't reasonably be counted without ToList.

Best regards


2015-03-26 13:45 GMT+01:00 Paul <[email protected]>:

> Thats so weird....
>
> Thanks man
>
> Paul
>
> On Wednesday, March 25, 2015 at 6:36:56 PM UTC-3, Gunnar Liljas wrote:
>
>> You need to Count before the projection.
>>
>> Feel free to report this as a bug. NH could throw away the projection
>> when counting.
>>
>> /G
>>
>> 2015-03-25 20:19 GMT+01:00 Paul <[email protected]>:
>>
>>> I have the following query:
>>> var list = repositoy.Query<MyClass>.Select(domain => new MyDto()
>>>      {
>>>          Id = domain.Id,
>>>          StringComma = string.Join(",", domain.MyList.Select(y => y.Name
>>> ))
>>>      });
>>>
>>> That works great:
>>> list.ToList();
>>>
>>> But if I try to get the Count I got an exception:
>>>
>>> list.Count();
>>>
>>> Exception
>>>
>>> NHibernate.Hql.Ast.ANTLR.QuerySyntaxException
>>>
>>> A recognition error occurred. 
>>> [.Count[MyDto](.Select[MyClass,MyDto](NHibernate.Linq.NhQueryable`1[MyClass],
>>>  Quote((domain, ) => (new MyDto()domain.Iddomain.Name.Join(p1, 
>>> .Select[MyListClass,System.String](domain.MyList, (y, ) => (y.Name), ), 
>>> ))), ), )]
>>>
>>>
>>>
>>> Any idea how to fix that whithout using ToList ?
>>>
>>> I posted that on StackOverflow as well
>>>
>>> http://stackoverflow.com/questions/29262271/nhibernate-
>>> query-with-subselect-count-error
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "nhusers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/nhusers.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/nhusers.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to