Mid From PDF EF Core Entity Framework Core

How to write joins (inner, left) in LINQ with EF Core?

  • Inner join example:
var query = from c in context.Customers

join o in context.Orders on c.Id equals o.CustomerId

select new { c.Name, o.OrderDate };

  • Left join (using DefaultIfEmpty()):
var query = from c in context.Customers

join o in context.Orders on c.Id equals o.CustomerId

into orders

from o in orders.DefaultIfEmpty()

select new { c.Name, OrderDate = o != null ? o.OrderDate

: (DateTime?)null };

More from Entity Framework Core Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details