Query materialization after GroupBy leads to "unexpected" results
See original GitHub issueIt 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:
- Created 7 years ago
- Comments:13 (12 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
More like a fix for #356
Thank you! I needed to set Configuration.Linq.GuardGrouping = false. 👍