-
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
ICollection.Contains isn't working properly with Enums in the DbSet<>.Where #18970
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Milestone
Comments
RebelionTheGrey
changed the title
DbSet<WhereICollection.Contains isn't working properly with Enums.
ICollection.Contains isn't working properly with Enums in the DbSet<>.Where
Nov 18, 2019
Note for triage: repros on 3.1. SQL generated is: SELECT [u].[Id], [u].[Name], [u].[Password], [u].[WorkingRoles]
FROM [Users] AS [u]
WHERE CAST(1 AS bit) = CAST(0 AS bit) /cc @maumar @smitpatel |
We cannot translate Contains over |
@smitpatel So we should throw then, right? |
Yup. Somewhere I guess we saw different types and converted it to false. |
smitpatel
added
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
and removed
easy-win
labels
Dec 13, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
DbContext.DbSet.Where
isn't work properly withICollection<T>
, whereT
is anEnum
.So, for example, the code like this always return emply
ICollection<>
:var result = await context.Users.Where(e => e.WorkingRoles.Contains(sameRole)).ToListAsync();
but
sameCollection
in the code below isn't empty.Part of code to reproduce
Let's
context
be the scoped instance ofUserStoreDbContext
resolved by standard MS DI.So, in this method
resultUserCollection
always empty, butanotherResultUserCollection
not, it contains correct users which have askedrole
in theirWorkingRoles
collection.Further technical details
EF Core version: 3.1.0-preview3.19554.8
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: 3.1.100-preview3-014645
Operating system: Windows Server 2016.
IDE: Microsoft Visual Studio Community 2019 Preview Version 16.4.0 Preview 5.0
The text was updated successfully, but these errors were encountered: