Thanks -- added test case and applied these changes with modifications in
r662.

On Fri, Sep 26, 2008 at 11:23 AM, Duarte Nunes <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> In using Linq to Nhibernate I bumped into a bug (or feature): the SQL
> resulting from the statement categories.Select(category => new
> { category.Name, category.Items.Count }) would produce a query (select
> this_.Name, count(items1_.ID) from ...) without the necessary "group
> by name" statement.
>
> I made a quick and dirty fix for this (in the SelectArgumentsVisitor
> class):
>
> protected override NewExpression VisitNew(NewExpression expr)
> {
>        NewExpression newExpr = base.VisitNew(expr);
>        _transformer = new
> TypeSafeConstructorMemberInitResultTransformer(expr);
>
>        var aggregators = expr.Arguments.Where(arg => arg is
> MethodCallExpression &&
>
> SupportsMethod(((MethodCallExpression)arg).Method.Name));
>        if (aggregators.Any())
>        {
>                foreach (var exp in expr.Arguments.Except(aggregators))
>                {
>                        string propertyName =
> MemberNameVisitor.GetMemberName(_rootCriteria, exp);
>
>  _projections.Add(NHProjections.GroupProperty(propertyName));
>
>                }
>        }
>
>        return newExpr;
> }
>
> Regards,
> Duarte
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"NHibernate Contrib - Development Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com.ar/group/nhcdevs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to