question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query materialization after GroupBy leads to "unexpected" results

See original GitHub issue

It is possible to change linq2db behavior to call Enumerable version on GroupBy internally when query materialize and GroupBy call is the last in sequence? I am requesting it, because in our project we already had several situations when developers write code like that:

var dict = db.Table.GroupBy(_ => _.SomeKey).ToDictionary(_ => _.Key, _ => _.ToList());

instead of

var dict = db.Table.AsEnumerable().GroupBy(_ => _.SomeKey).ToDictionary(_ => _.Key, _ => _.ToList());

I think this behavior reflects developer’s intension in more proper way.

I’ll send pull request with test for current behavior.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
MaceWinducommented, Mar 20, 2017

More like a fix for #356

0reactions
filippobottegacommented, Apr 29, 2020

Configuration.Linq.GuardGrouping

Thank you! I needed to set Configuration.Linq.GuardGrouping = false. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Differences between GROUPBY and SUMMARIZE
SUMMARIZE should be used to group by model and query columns. ... being very powerful – may lead to unexpected results and poor...
Read more >
Beginner SQL: Unexpected results from GROUP BY
In Access, the query design wizard lays out the group by and aggregates all in a single 'Totals row', so-to-speak. This had led...
Read more >
Unexpected behavior in Oracle when using Group By with ...
Query 2: SELECT ID FROM VIEW_X WHERE PART_2_ID IN ('K1') GROUP BY ID HAVING COUNT(DISTINCT(PART_2_ID)) = 1;. Results: ID -- 2.
Read more >
12 Advanced Query Rewrite for Materialized Views
Creating Result Cache Materialized Views with Equivalences ... FROM , WHERE , HAVING , or GROUP BY ) of a query with those...
Read more >
GROUP BY vs DISTINCT -- SQL SERVER BUG
I used DISTINCT to check my results with a logically equivalent query, but it doesn't allow using aggregates. Even though there are different ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found