📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

377 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

LINQ

LINQ to Objects, LINQ to SQL concepts and LINQ to Entities, deferred and immediate execution, IEnumerable and IQueryable, expression trees and common LINQ performance mistakes.

  1. How does LINQ to Objects work under the hood? Explain how operators like Where and Select are implemented as extension methods and iterators, query syntax versus method syntax, streaming versus buffering operators, and the newer operators added in .NET 6 to .NET 10.

    LINQ to Objects internals: extension methods over IEnumerable, iterator pipelines, operator fusion and fast paths, query syntax translation, streaming versus buffering, and modern operators such as Chunk, CountBy, Index and LeftJoin.

    Mid-Level Theory LINQ Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  2. What was LINQ to SQL, and which of its concepts still matter for a .NET 10 developer using EF Core? Explain the provider model, DataContext and change tracking, identity map, deferred loading, parameterised SQL generation and why LINQ to SQL is not available on modern .NET.

    LINQ to SQL as the original IQueryable provider: its architecture and lasting concepts (translation, change tracking, identity map, lazy loading, parameterisation) and how they map to EF Core today.

    Mid-Level Theory LINQ Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  3. How does LINQ to Entities work in EF Core 10? Explain how a LINQ query is translated to SQL, what can and cannot be translated, client evaluation rules, tracking versus no-tracking, split queries, compiled queries, and how you inspect and tune the generated SQL.

    LINQ to Entities with EF Core: the query pipeline, translation limits and client evaluation, tracking, projections, split queries, compiled queries and SQL inspection tools.

    Senior Theory LINQ Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  4. A colleague's LINQ code behaves strangely: a filtered list seems to change after it was built, a database query throws ObjectDisposedException, logging shows the same query running three times, and an exception appears far from the line that caused it. Explain deferred execution and how you would debug and fix each symptom.

    Deferred execution in practice: when queries run, captured variables, multiple enumeration, disposed contexts, late exceptions, and the tools and rules that prevent these bugs.

    Mid-Level Debugging LINQ Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  5. Which LINQ operators cause immediate execution, and how do you choose between ToList, ToArray, ToDictionary, ToHashSet, ToLookup and the async versions? Explain the cost of each, single-item operators like First, Single and Any, and how to materialise efficiently.

    Immediate execution in LINQ: scalar and collection operators, First versus Single versus Any, choosing the right materialisation, async materialisation in EF Core, and allocation costs.

    Junior Theory LINQ Β· πŸ”— 2 follow-ups
  6. What is IEnumerable<T> really? Explain the IEnumerable/IEnumerator contract, how foreach is compiled (including the pattern-based GetEnumerator and struct enumerators), enumerator disposal, IAsyncEnumerable<T>, and when a method should accept or return IEnumerable<T>.

    IEnumerable<T> and IEnumerator<T> in depth: the contract, foreach lowering, struct enumerators and boxing, disposal, async streams, and API design guidance on accepting and returning sequences.

    Mid-Level Theory LINQ Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  7. What is IQueryable<T>, and how is it different from IEnumerable<T>? Explain Expression, ElementType and Provider, how Queryable methods build expression trees, why the static type of a variable decides where a query runs, AsEnumerable and AsQueryable, and whether a repository should expose IQueryable.

    IQueryable<T>: the provider model, Queryable versus Enumerable overload binding, crossing between database and memory with AsEnumerable, and the design debate about exposing IQueryable.

    Senior Theory LINQ Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. What are expression trees in C#? Explain how the compiler turns a lambda into an Expression<TDelegate>, how to build, inspect and compile expression trees at run time, how LINQ providers and libraries use them, what C# features cannot appear in them, and the performance and AOT costs of Compile().

    Expression trees: code as data, compiler-generated trees from lambdas, building and visiting trees, combining predicates, Compile cost and caching, interpretation under Native AOT, and language limitations.

    Senior Coding LINQ Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  9. Code review: this order-reporting code mixes EF Core and LINQ to Objects. It calls ToList() before Where, uses Count() > 0, calls FirstOrDefault on a list inside a loop, does OrderBy().First(), enumerates the same query several times, loads related data inside a foreach, and builds IN lists with Contains over 50,000 ids. Find the LINQ performance mistakes and rewrite it.

    A code review of the most common LINQ performance mistakes in .NET 10 services, in memory and against EF Core, with the reasoning and the rewrite for each.

    Senior CodeReview LINQ Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me