Tutorials Entity Framework Core Tutorial
Joining with LINQ in EF Core
Joining with LINQ in EF Core: free step-by-step lesson with examples, common mistakes, and interview tips — part of Entity Framework Core Tutorial on Toolliyo Academy.
On this page
Entity Framework Core Tutorial · Lesson 38 of 100
Joining with LINQ in EF Core
Beginner ✓ → Intermediate → Advanced → Professional
Intermediate · 2 — Data & queries · ~6 min · Module 4: LINQ
What is this?
Joins combine related tables using navigation properties with Include, or explicit join/SelectMany LINQ. EF generates SQL JOINs.
Why should you care?
ShopNest order reports need customer name beside order total — joins fetch related data in one round trip when shaped correctly.
See it live — copy this example
Paste into a .NET project with EF Core packages, then run with LocalDB/SQL Server (dotnet ef / dotnet run).
var report = await (
from o in _context.Orders
join c in _context.Customers on o.CustomerId equals c.Id
where o.OrderDate >= start && o.OrderDate < end
orderby o.OrderDate descending
select new OrderSummaryDto
{
OrderId = o.Id,
CustomerEmail = c.Email,
Total = o.Items.Sum(i => i.Quantity * i.UnitPrice)
}).Take(100).ToListAsync();
What happened?
- join syntax pairs Orders and Customers on Id.
- Nested Sum on Items may translate to subquery or join depending on model — inspect ToQueryString.
Practice next
- Prefer navigation joins when relationships exist.
- Compare Include vs Select projection join cost.
- Filter both sides early in Where before join.
- Rewrite join syntax using o.Customer navigation in Select.
- Left join pattern with DefaultIfEmpty for customers without orders.
Remember
Joins combine entities in LINQ or SQL. Navigation properties simplify many joins. Project to DTO to control join shape.
ShopNest finance export
Finance team exports last hundred orders with customer email via LINQ join.
Outcome: Single query CSV export instead of N+1 customer lookups.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!