-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group by property that has a converted value throws exception #28300
Comments
Duplicate of #19929 |
@smitpatel could you please point me to the sub-issue mentioned int #19929 that would cover this one? As far as I can tell, there's only #17653 open, but I cannot really see how it would be related. |
Oh, I wasn't aware, that |
@dccs-pwurzinger note that GroupBy is supported for properties, but you currently need to apply an aggregate operator afterwards - this is necessary in order to translate to a SQL GROUP BY clause: var foo = context.Orders
.GroupBy(o => o.CustomerID)
.Select(g => new {
CustomerID = g.Key,
Count = g.Count()
}); What's not currently supported is GroupBy without a subsequent aggregate operator (that's what #19929 tracks). |
Yeah that's what I meant, I should have read my answer before sending it - I will edit it afterwards, just to make sure somebody stumbling across that issue does not make wrong assumptions. With the solution you mentioned it's possible to group by properties that have a value conversion as well. Thanks! |
This still fails with EF7 RC2. but is closed as a duplicate of #19929.
|
File a bug
This bug adresses a scenario, in which an entity has a property, whichs value is being converted between its CLR representation and its DB representation.
Consider the following model:
with somewhere a
DbSet<Entity>
being available.If you want to simply project
SomeEnum
, that works fine:But grouping by that property throws an exception:
To answer that question in advance: I expected the query to group by the DB representation of the property (the string value, in this case).
Include your code
The bug should be reproducible using the code below, with
Microsoft.EntityFrameworkCore.Sqlite
being installed as NuGet reference (version see below).Include stack traces
Include provider and version information
EF Core version: 6.0.4, but tried with latest 7.0-preview as well
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 6.0
Operating system: Win10 Enterprise
IDE: VS 2022
The text was updated successfully, but these errors were encountered: