Stage 2 · Lesson 3 of 6
Deferred execution, IEnumerable and IQueryable
A query does nothing when you write it. It runs when you enumerate it: in a foreach, or when you call ToList, Count, First and similar. Enumerating twice runs it twice, which against a database means two round trips.
IEnumerable<T> runs LINQ in memory with ordinary C# functions. IQueryable<T> builds an that EF Core translates into SQL, so filters run inside . Once something becomes an IEnumerable, every later step runs in your app over whatever was already loaded.
This is why a helper that accepts IEnumerable<Order> and then filters can quietly pull a million rows into memory. Learning this now saves you from the most common EF Core performance bug in stage 4.
Common trapreturning a deferred query from a method after its has been disposed.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Data Structures & Algorithms for Coding Interviews
Design Gurus · Beginner · Subscription
Arrays, hash tables, lists, stacks and queues: what every C# collection is built on, with complexity explained
- GuideFree.NET documentation
Microsoft
Free official guides on LINQ, generics, collections and the asynchronous programming model