-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Labels
Milestone
Description
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; }
}