You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Enum.GetValues together with .HasFlags to produce a collection of enum values in an object from DB int column the SQL is generated, but it contain superfluous _ord column in select, which is not part of VALUES. This results in a runtime exception as selecting the _ord fails.
SELECT [t].[Id], [v0].[Value], [v0].[_ord]
FROM [TestEntities] AS [t]
OUTER APPLY (
SELECT [v].[Value], [v].[_ord]
FROM (VALUES (CAST(0ASint)), (1), (2), (4), (8)) AS [v]([Value])
WHERE [t].[SomeEnum] & [v].[Value] = [v].[Value] AND [v].[Value] <>0
) AS [v0]
ORDER BY [t].[Id], [v0].[_ord]
Bug description
When using Enum.GetValues together with .HasFlags to produce a collection of enum values in an object from DB int column the SQL is generated, but it contain superfluous
_ord
column in select, which is not part of VALUES. This results in a runtime exception as selecting the_ord
fails.Example code:
Example of generated SQL:
Your code
Minimal project to reproduce:
Repli1.zip
Stack traces
Verbose output
EF Core version
9.0.3
Database provider
Microsoft.EntityFrameworkCore.SqlServer
Target framework
.NET 8
Operating system
Windows 11
IDE
Visual Studio 2022 17.10.4
The text was updated successfully, but these errors were encountered: