What is eager loading?
Short answer: How is .Include() / .ThenInclude() used? Eager loading loads related data as part of the initial query, reducing round-trips to the database. ✅ Use .Include() to load related entities: var blogs = context.Blogs .Include(b => b.Posts) .ToList(); Use .ThenInclude() for deeper nesting: context.Blogs .Include(b => b.Posts) .ThenInclude(p => p.Comments); Eager loading prevents lazy load performance issues and the N+1…
Real-world example (ShopNest)
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png