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
@Oskar Berggren he said:
"The latest version does not support this feature, and hope to see this feature as soon as possible! NHibernate team, refuel!"
Following query does not work:
It produces following sql:
Which is semantically identical to following linq query:
But it should work as count distinct