Linq group counting does not work
Activity

Thomas-Louis Simard April 30, 2017 at 4:01 PM
Try this as a workaround :

Frédéric Delaporte March 4, 2017 at 6:48 PM
The Distinct().Count()
workaround fails with multiple grouping key. It looks like we have no workaround for this case.
Fails with NotSupportedException
: new <>f__AnonymousType4`2(ShippingDate = [100001].ShippingDate, ShippedTo = [100001].ShippedTo)
(Seems to be the type name put as the exception message. Fails at VisitExpression
, at VisitNhDistinct
in HqlGeneratorExpressionTreeVisitor
.)
Indeed, this would require a sub query in the from
statement, which is unsupported by HQL as far as I know.
This would imply below query can not be supported:
I wonder then if NHibernate should really try to translate the "unique grouping key then count" case to a "distinct then count", as the more general group by
case would still fails.

Frédéric Delaporte March 4, 2017 at 6:19 PM(edited)
Following query, tried as a workaround, fails too:
It issues:
This means this bug likely affects all aggregates.

Bilal Fazlani July 10, 2014 at 10:27 AM
Hi,
Is this issue fixed?, or anyone working on it ?

Alex Zaytsev February 23, 2013 at 10:52 PM
he said:
"The latest version does not support this feature, and hope to see this feature as soon as possible!
NHibernate team, refuel!"
Details
Details
Assignee
Reporter

Following query does not work:
It produces following sql:
Which is semantically identical to following linq query:
But it should work as count distinct