A value type (int, struct) is copied when assigned: you get your own copy. A reference type (class) is shared: both variables point to the same object.
Say it like this in the interview
“Value types hold their data directly and are copied on assignment; reference types hold a reference to a heap object. Structs suit small immutable data; classes suit entities with identity.”
It guarantees that a resource (file, connection) is closed when you’re done, even if an error happens.
Say it like this in the interview
“using calls Dispose at the end of the scope, like try/finally. using var declarations dispose at the end of the enclosing scope. HttpClient is an exception: reuse it via IHttpClientFactory.”
.Result makes the current thread stand and wait. If the async work needs that same thread to finish, both wait for each other forever: a deadlock. In web apps it also wastes threads.
Say it like this in the interview
“Blocking on async code with .Result or .Wait() can deadlock in contexts with a synchronization context and causes thread-pool starvation. I use async all the way down, ConfigureAwait(false) in libraries, and avoid async void except event handlers.”
Injecting a scoped thing (like a DbContext) into a singleton is a classic bug: it lives forever and is shared across requests.
Say it like this in the interview
“Transient per resolution, scoped per request, singleton per app. DbContext is scoped. A singleton must never capture a scoped service; the framework validates this in development.”
Each request passes through a chain of components in the order you add them: logging, HTTPS redirect, authentication, routing, your endpoint.
Say it like this in the interview
“Middleware components registered in Program.cs form a pipeline; each can handle the request or call next. Order matters: exception handling first, then HTTPS, static files, routing, authentication, authorisation, endpoints.”
LINQ lets you query lists (and databases through EF) with chained steps like SQL: group, sum, sort, take.
var top = orders
.GroupBy(o => o.CustomerId)
.Select(g => new { CustomerId = g.Key, Total = g.Sum(o => o.Amount) })
.OrderByDescending(x => x.Total)
.Take(3)
.ToList();
Say it like this in the interview
“Group by customer, project the sum, order descending, take three. With EF Core this is translated to SQL; ToList() executes it. Deferred execution means the query runs only when enumerated.”
IQueryable builds a database query that runs on the server. IEnumerable works on data already in memory. Calling .ToList() too early pulls everything into memory.
Say it like this in the interview
“IQueryable expression trees are translated to SQL; IEnumerable operates in memory with LINQ to Objects. Filtering after materialising loads the whole table, so I filter before ToList().”
Fetch only what you need, don’t track objects you won’t edit, and avoid one query per row.
Say it like this in the interview
“AsNoTracking() for read-only queries, projections with Select instead of loading full entities, Include to avoid N+1 or split queries for large graphs, proper indexes, pagination, and checking the generated SQL via logging.”