LINQ translation, IQueryable and IEnumerable, deferred execution, projection, Include and ThenInclude, eager, explicit and lazy loading, split queries, filtered Include and no-tracking queries in EF Core 10.
-
EF Core throws 'The LINQ expression could not be translated'. How do you fix it without moving the whole query to memory?
Junior
Theory
Querying
-
Why can wrapping a column in a function in an EF Core query, such as ToLower() or .Year, make it slow even though it translates?
Intermediate
Theory
Querying
-
How do you reuse a projection expression across several EF Core queries without breaking translation?
Mid-Level
Theory
Querying
-
When would you use snapshot isolation or RCSI with EF Core on Azure SQL, and what does it cost?
Mid-Level
Theory
Querying
-
Why does calling Update() on a disconnected entity cause EF Core to write every column, and what would you do instead?
Intermediate
Theory
Querying
-
Why does offset pagination get slower on deep pages, and how does keyset pagination fix it in EF Core?
Mid-Level
Coding
Querying
-
In EF Core, what is the practical difference between IQueryable<T> and IEnumerable<T>? Where does a Where filter actually run in each case, and what goes wrong when someone calls AsEnumerable() or returns IEnumerable<T> from a repository too early?
Covers where EF Core queries execute depending on IQueryable versus IEnumerable, how the static type decides SQL versus in-memory filtering, and the AsEnumerable() and early-materialisation traps.
Junior
Theory
Querying
Β· π 3 follow-ups
-
How does EF Core translate a LINQ query into SQL? What kinds of expressions translate, where is client evaluation still allowed, what happens when something cannot be translated, and how do you check the SQL EF Core will send?
Covers EF Core's query pipeline, which LINQ constructs and methods translate to SQL Server, the final-projection client-evaluation rule, translation exceptions and how to inspect SQL with ToQueryString() and LogTo.
Intermediate
Theory
Querying
Β· π 2 follow-ups
-
How do you load related data in EF Core? Explain eager loading with Include and ThenInclude, explicit loading, and lazy loading, when you would use each, and what filtered Include lets you do.
Covers EF Core's three ways to load navigations (eager with Include/ThenInclude, explicit with Entry().Collection().Load, lazy with proxies), filtered Include, the SQL each produces and when to choose each.
Junior
Theory
Querying
Β· π 2 follow-ups
-
For a read-only API endpoint, would you load data with Include or project it with Select into a DTO? Explain the difference in the SQL, over-fetching, what each means for change tracking, and when Include is still the right choice.
Covers Select projection versus Include in EF Core: generated SQL, columns and rows transferred, tracking behaviour of projected DTOs and entities, projecting collections and aggregates, and when Include is still correct.
Mid-Level
Theory
Querying
Β· π 3 follow-ups Β· π 1 real-world
-
What is cartesian explosion in EF Core, and how do split queries help? Explain what AsSplitQuery() changes in the SQL, the consistency and round-trip trade-offs, and how you decide between single queries, split queries and projection.
Covers cartesian explosion from multiple collection Includes, how AsSplitQuery() and UseQuerySplittingBehavior change the generated SQL, consistency and ordering caveats, round-trip costs, and choosing between single, split and projected queries.
Mid-Level
Theory
Querying
Β· π 2 follow-ups Β· π 1 real-world
-
What is the difference between a tracking query, AsNoTracking() and AsNoTrackingWithIdentityResolution() in EF Core? What does each cost, how does each handle the same row appearing twice, and which would you use where?
Covers EF Core tracking versus no-tracking queries, identity resolution, snapshot and identity-map costs, QueryTrackingBehavior defaults, and when to choose tracking, AsNoTracking or AsNoTrackingWithIdentityResolution.
Intermediate
Theory
Querying
Β· π 3 follow-ups
-
Your ASP.NET Core API uses EF Core with lazy loading proxies. One endpoint returns entities directly and now either throws a JSON 'possible object cycle' exception or runs dozens of SQL queries per request. How do you diagnose and fix it?
Covers diagnosing lazy-loading N+1 queries and serialisation cycles in an ASP.NET Core API with EF Core: SQL logging, Application Insights, the System.Text.Json cycle error, and fixing with DTO projection, explicit loading strategy and turning lazy loading off.
Mid-Level
Debugging
Querying
Β· π 2 follow-ups Β· π 1 real-world
-
Show how you would build a search endpoint in EF Core with optional filters, a client-chosen sort column and paging. How do you compose IQueryable safely, combine predicates with expressions, avoid SQL injection and plan-cache problems, and keep the query translatable?
Covers composing dynamic EF Core queries: conditional IQueryable filters, combining Expression<Func<T,bool>> predicates (OR with PredicateBuilder-style code), whitelisted sorting, stable paging, parameterisation, and checking translation.
Mid-Level
Coding
Querying
Β· π 3 follow-ups Β· π 1 real-world
-
What deferred-execution problems are specific to EF Core? Walk through a query enumerated twice, a query returned from a method and enumerated after the DbContext is disposed, and an unmaterialised query used inside a loop that also writes. When would you buffer with ToListAsync() and when would you stream with AsAsyncEnumerable()?
Covers EF Core-specific deferred-execution failures (repeated database round trips, ObjectDisposedException after scope end, open-reader conflicts and second-operation errors) and the buffering versus streaming choice between ToListAsync() and AsAsyncEnumerable().
Senior
Theory
Querying
Β· π 3 follow-ups Β· π 1 real-world
-
Code review: a customer dashboard API action in EF Core calls ToList() on Customers before Where, checks Count() > 0, Includes every navigation, calls FirstOrDefault against the database inside a loop over orders, and searches with Name.ToLower().Contains(term). What do you flag, in what order, and what does the rewrite look like?
A code review of an EF Core dashboard action: client-side filtering after ToList(), Count() > 0 instead of Any(), over-eager Include, a database FirstOrDefault inside a loop (N+1), non-sargable ToLower() search, tracking and sync calls; ranked by severity with a projected rewrite.
Mid-Level
CodeReview
Querying
Β· π 3 follow-ups Β· π 1 real-world