Skip to content
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

Obsoleted ToQuery stopped working #24623

Closed
roji opened this issue Apr 9, 2021 · 2 comments · Fixed by #25870
Closed

Obsoleted ToQuery stopped working #24623

roji opened this issue Apr 9, 2021 · 2 comments · Fixed by #25870
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@roji
Copy link
Member

roji commented Apr 9, 2021

In 9f63014, EntityTypeBuilder<TEntity>.ToQuery works, in d240c89 it doesn't (it's ignored). Did we do anything intentional here?

Repro
await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();

_ = ctx.Blogs.ToList();

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

    static ILoggerFactory ContextLoggerFactory
        => LoggerFactory.Create(b => b.AddConsole().AddFilter("", LogLevel.Information));

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseSqlServer(@"Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0")
            .EnableSensitiveDataLogging()
            .UseLoggerFactory(ContextLoggerFactory);

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<BlogQuery>().HasNoKey().ToQuery(() => Set<BlogQuery>().FromSqlRaw("SELECT * FROM Blogs -- RAW"));
        // modelBuilder.Entity<BlogQuery>().HasNoKey().ToSqlQuery("SELECT * FROM Blogs -- RAW");
    }
}

public class BlogQuery
{
    public int Id { get; set; }
    public string Name { get; set; }
}
@ajcvickers
Copy link
Member

@roji to further investigate

@roji
Copy link
Member Author

roji commented Apr 10, 2021

Offending commit: 4722fe3

Running the above repro with the previous commit (20e2cd4) queries with the specified raw SQL (with the -- RAW comment), whereas with 4722fe3 the raw SQL isn't used.

/cc @AndriySvyryd

@ajcvickers ajcvickers added this to the 6.0.0 milestone Apr 16, 2021
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 3, 2021
@AndriySvyryd AndriySvyryd removed their assignment Sep 3, 2021
AndriySvyryd added a commit that referenced this issue Sep 3, 2021
AndriySvyryd added a commit that referenced this issue Sep 4, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-rc2 Sep 8, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0-rc2, 6.0.0 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants