Skip to content

SQL Server: index over inline/constant list fails #37561

@roji

Description

@roji

With SQL Server compat level 170,

int[] ints = [1, 2, 3];
_ = context.Blogs.Where(b => EF.Constant(ints)[b.Id] == 1).ToList();
Minimal repro
await using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

int[] ints = [1, 2, 3];
_ = context.Blogs.Where(b => EF.Constant(ints)[b.Id] == 1).ToList();

public class BlogContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseSqlServer(Environment.GetEnvironmentVariable("Test__SqlServer__DefaultConnection"), o => o.UseCompatibilityLevel(170))
            .LogTo(Console.WriteLine, LogLevel.Information)
            .EnableSensitiveDataLogging();
}

public class Blog
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions