-
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
IQueryable.All evaluate to false with predicate _ => true #23617
Comments
@tomek-anuszkiewicz I am not able to reproduce this. Copying that code into the GetStarted sample and running it does not generate an exception for me. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
I'm confused. On my home PC it works as you said. But on my company notebook for
It also the same for Azure App Service because there where the error was spotted. Sample project: |
Note for triage: this looks like a regression from 3.1 to 5.0. Logs from 3.1:
Logs from 5.0:
Code: class Program
{
static void Main()
{
using (var db = new BloggingContext())
{
db.Database.EnsureDeleted();
db.Database.EnsureCreated();
// Create
Console.WriteLine("Inserting a new blog");
db.Add(new Blog { Url = "http://blogs.msdn.com/adonet" });
db.SaveChanges();
var all = db.Blogs.ToList().All(_ => true);
var all2 = db.Blogs.All(_ => true);
if (all != all2)
throw new Exception("Why?");
}
}
}
public class BloggingContext : DbContext
{
private static ILoggerFactory ContextLoggerFactory
=> LoggerFactory.Create(b => b.AddConsole()); //.SetMinimumLevel(LogLevel.Information));
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options
.UseLoggerFactory(ContextLoggerFactory)
.UseSqlite("Data Source=blogging.db");
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public List<Post> Posts { get; } = new List<Post>();
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public Blog Blog { get; set; }
} |
@maumar - This could be some optimization which works on |
…true We have optimization for EXISTS, that returns false when the subquery has a predicate which filters out all the rows. In such case we return constant false. However, ExistExpression also stores information about it being negated or not (i.e. EXISTS vs NOT EXISTS). If the Exists expression is negated and the predicate filters out all the rows we should return true instead.
…true We have optimization for EXISTS, that returns false when the subquery has a predicate which filters out all the rows. In such case we return constant false. However, ExistExpression also stores information about it being negated or not (i.e. EXISTS vs NOT EXISTS). If the Exists expression is negated and the predicate filters out all the rows we should return true instead. Fixes #23617
…true We have optimization for EXISTS, that returns false when the subquery has a predicate which filters out all the rows. In such case we return constant false. However, ExistExpression also stores information about it being negated or not (i.e. EXISTS vs NOT EXISTS). If the Exists expression is negated and the predicate filters out all the rows we should return true instead. Fixes #23617
IQueryable.All evaluate to false with predicate _ => true
With https://github.com/dotnet/EntityFramework.Docs/tree/master/samples/core/GetStarted
Modify
Program.cs
like:Shouldn't
Blogs.All(_ => true)
evaluate totrue
likedb.Blogs.ToList().All(_ => true)
?EF Core version: 5
Database provider: Sqlite
Target framework: NET5
Operating system: Windows
IDE: VS2019
The text was updated successfully, but these errors were encountered: