Thanks for your thoughts Fabian. Turns out there was an
implementation for an AggregateResultOperator, which you've apparently
now implemented yourselves. Adding the Aggregate and
AggregateFromSeed result operators made things make sense again.
I am seeing another strange problem. I have an expression that looks like:
(sb, name) => sb.Length > 0 ? sb.Append(", ").Append(name) : sb.Append(name)
Unfortunately, by the time it gets to the AggregateBySeed, the
expression looks something like:
sb => sb.Length > 0 ? sb.Append(", ").Append([100001].name) :
sb.Append([100001].name))
I haven't had time to analyze why "name" was eaten, but I wonder if
the new operators have an undetected relinq bug.
Patrick Earl
On Tue, Feb 8, 2011 at 4:16 AM, Fabian Schmied <[email protected]> wrote:
> This is a guess without seeing any of the exceptions:
>
> You (ie., some committer to NH) probably worked around a missing expression
> parser for Queryable.Aggregate in a previous version of re-linq by handling
> the respective MethodCallExpressions in an expression visitor. In the
> current version, re-linq now recognizes the Aggregate methods as query
> operators and converts them into
> AggregateResultOperator/AggregateFromSeedResultOperator instances (similar
> to what it does for all query operators).
>
> This means the code previously handling the MethodCallExpressions for
> Queryable.Aggregate should now be rewritten to handle the result operators
> instead.
>
> In general, whenever you have a query operator that's not detected by
> re-linq, please don't write code handling the MethodCallExpressions
> directly, but instead add an expression parser (IExpressionNode
> implementation) for that method. This approach has several advantages, among
> others that you avoid breaking your code with later versions of re-linq. See
> my blog post
> (https://www.re-motion.org/blogs/mix/archive/2010/10/28/re-linq-extensibility-custom-query-operators.aspx),
> and post to the re-motion-users mailing list if there are any
> questions/problems (or if re-linq is missing a standard query operator).
>
> (Out of curiosity: If I'm guessing correctly, _how_ do you actually
> translate the Aggregate query operator to HQL? After all, the aggregation
> function could contain completely arbitrary code...)
>
> Regards,
> Fabian