on-internet
← Community

Does querying multiple EF Core DbSets in a single LINQ call result in a single query to the database?

Stack Overflow ·

An IQueryable<> is a declaration of intent, the code is only executed when called by a consuming method. I worry I'll accidentally execute it by calling foreach()/ToList() or .first() within the call. Having an EF Core DbContext class setup and Foo and Bar classes, would the following LINQ query execute as a single query against the database? Or does each call to DbSet<> separately call the database? public class DbContext { public DbSet<Foo> Foo { get; set; } public DbSet<Bar> Bar { get; set; } } public class Foo { public string Id { get; set; } public string BarId { get; set; } } public clas

Comments

Sign in or sign up to comment and upvote.

No comments yet.