GroupBy doesn't work

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
LPCRoy
Posts: 7
Joined: Mon 18 May 2009 20:45

GroupBy doesn't work

Post by LPCRoy » Thu 21 May 2009 01:48

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

LPCRoy
Posts: 7
Joined: Mon 18 May 2009 20:45

Post by LPCRoy » Thu 21 May 2009 04:31

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 22 May 2009 10:11

Thank you for your help, this error was reproduced.
I will let you know when it is fixed.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 16 Jun 2009 14:36

We have fixed this problem, the fix will be included in the next build.

Post Reply