Page 1 of 1

GroupBy doesn't work

Posted: Thu 21 May 2009 01:48
by LPCRoy
Hi,

GroupBy completley doesn't work with the PostgreSql adapter. For example

Code: Select all

from stats in dataContext.Stats
                            where stats.Metric.MetricName == "Foo"
                                && stats.IsValid == "Y"
                            group stats by stats.Value into Values                           
                            select new { ValueName = Values.Key.ValueName, Count = Values.Count()};
Generates the following SQL, which is clearly incorrect, it's missing the GROUP BY Statement:

Code: Select all

SELECT t4.value_name AS "ValueName", COUNT(*) AS "C1"
FROM (
    SELECT t2.id_value
    FROM public.stats t2
    INNER JOIN public.metric t3 ON t2.id_metric = t3.id_metric
    WHERE (t3.metric_name = :p0) AND (t2.is_valid = :p1)
    ) t1
INNER JOIN public.values t4 ON t1.id_value = t4.id_value


Any ideas on when this will be fixed?

Thanks,
Roy

Posted: Thu 21 May 2009 04:31
by LPCRoy
The problem appears to be doing a GroupBy on a navigation property. When I switch the GroupBy to be by the Id column of the navigation property, everything works (Sort of, still more bugs I had to work around). This works fine in LinqToSql and the Entityramework, so I would expect it to work with your provider as well.

As a general principal, I would ask you guys to please make sure you're passing the 101 LINQ samples before shipping a provider.

Posted: Fri 22 May 2009 10:11
by AndreyR
Thank you for your help, this error was reproduced.
I will let you know when it is fixed.

Posted: Tue 16 Jun 2009 14:36
by AndreyR
We have fixed this problem, the fix will be included in the next build.