-
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
Regression when using ImmutableArray's Contains, while Array's Contains method still works. #35102
Comments
Confirmed regression from 8.0 to 9.0; not specific to SQLite. await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
ImmutableArray<string> tags = ["foo", "bar"];
// List<string> tags = ["foo", "bar"]; // This works
var existingEntities = await context
.Tags.Where(t => tags.Contains(t.Value))
.ToArrayAsync();
public class BlogContext : DbContext
{
public DbSet<Tag> Tags { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
}
public class Tag
{
public int Id { get; set; }
public string Value { get; set; }
} @cincuranet assigning to you as you worked in this area in 9.0, IIRC. |
@roji please see additional examples of similar issues. See repo with examples Thanks, |
Confirmed regression from 8.0 to 9.0; - Postgres.
Temporary fixed with AsEnumerable |
@cincuranet note npgsql/efcore.pg#3385 which is about FrozenSet, but seems to be the same issue otherwise. |
Glad this resolution is coming. We are dealing with this as well. |
File a bug
I ran into a regression going from 8.0.1 to 9.0.0 using the Sqlite provider. I have some code which is checking if the string value of a column (column name Value) is one of a number of values (using dbKeys.Contains). dbKeys was an ImmutableArray, I found if I used an Array instead it start to work. But I don't see any reason it shouldn't keep working with an ImmutableArray.
Include your code
The following code using ToImmutableArray stopped working when going from 8.0.1 to 9.0.0:
But it works if I use ToArray():
Include stack traces
Include provider and version information
EF Core version: regressed with version 9.0.0, worked for version 8.0.1
Database provider: Microsoft.EntityFrameworkCore.Sqlite regressed with version 9.0.0, worked for version 8.0.1
Target framework: regression seen with net9.0, worked with net8.0
Operating system: Windows 11 Home
IDE: JetBrains Rider 2024.2.5
The text was updated successfully, but these errors were encountered: