At the moment ExpressionEqualityComparer handles only arrays for structural comparison. We should consider handling other types of collections.
At the moment it is visible in query cache misses in #37112. But also this code:
using Microsoft.EntityFrameworkCore;
await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
// This emits 2 query compilation events.
_ = await context.Blogs.Where(b => new List<int> { 1, 2, 3 }.Contains(b.Id)).ToListAsync();
_ = await context.Blogs.Where(b => new List<int> { 1, 2, 3 }.Contains(b.Id)).ToListAsync();
// This emits 1 query compilation event.
_ = await context.Blogs.Where(b => new[] { 1, 2, 3 }.Contains(b.Id)).ToListAsync();
_ = await context.Blogs.Where(b => new[] { 1, 2, 3 }.Contains(b.Id)).ToListAsync();
public class BlogContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlite("Data Source=repro.db")
.LogTo(Console.WriteLine, filter: (eventid, _) => eventid.Name == "Microsoft.EntityFrameworkCore.Query.QueryCompilationStarting")
.EnableSensitiveDataLogging();
}
public class Blog
{
public int Id { get; set; }
public string Name { get; set; }
}
EDIT: this means that we get query cache misses, and recompile queries that have captured collection/enumerable variables (which aren't arrays/implement IStructuralComparable)
At the moment
ExpressionEqualityComparerhandles only arrays for structural comparison. We should consider handling other types of collections.At the moment it is visible in query cache misses in #37112. But also this code:
EDIT: this means that we get query cache misses, and recompile queries that have captured collection/enumerable variables (which aren't arrays/implement IStructuralComparable)