Using GroupBy
with auto-generated expression passed to Select
throws an exception in RC1 and RC2
#26525
Labels
GroupBy
with auto-generated expression passed to Select
throws an exception in RC1 and RC2
#26525
(Here's the runnable repo for the issue described below)
I have an expression visitor that replaces every occurrence of a method that's marked with a certain attribute with an expression that that method points to. It's not that complicated, and it used to work perfectly until I updated to RC1, and then RC2, it used to work in preview 7 and before.
This problem arises when I'm working with
GroupBy
.The code:
Imagine you have a
Purchase
entity that has aDatePurchased
property on it of typeDateTime
.I'm executing a query to figure out how many purchases took place on each day. The query will look like this. Note that the expression passed to the
Select
method gets generated on the fly by my expression visitor:Looks simple enough, huh? But I actually get an exception in RC1 and RC2. Prior to that there was no problem.
I even tried to compare two expressions, one written directly by hand and the other one generated by my visitor, using
ExpressionEqualityComparer
, and it returnstrue
, which confirms they're the same. Yet I get an exception for one and not for the other! Incredibly strange!I strongly recommend you clone the repo I linked to above, and see everything for yourself.
The errors:
I actually get two different exceptions on RC1 and RC2.
Here's the exception I get on RC2:
What does this even mean?! I googled the error message but no relevant search results came up.
And here's the one I get on RC1:
Provider and version information
EF Core version: from 6.0 RC1 (previously worked in 6.0 Preview 7)
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 6.0 RC)
Operating system: Windows 10 version 20H2 (build 19042.1288)
IDE: (e.g. Visual Studio 2022 RC - version 17.0.0 RC3)
I've been beating my head against the wall for the last few days and I have run out of ideas for what could be causing this. I'm convinced this is probably a subtle bug somewhere in the new RC versions of EF Core, as there was absolutely no problem prior to those versions.
The text was updated successfully, but these errors were encountered: