Skip to content

Joining

Context: Join operators (Join, GroupJoin) combine sequences based on matching keys.

var customers = new[] { new { Id = 1, Name = "Alice" }, new { Id = 2, Name = "Bob" } };
var orders = new[] { new { CustomerId = 1, Amount = 100 }, new { CustomerId = 1, Amount = 50 } };
var join = customers.Join(orders,
c => c.Id,
o => o.CustomerId,
(c, o) => new { c.Name, o.Amount });
// Name=Alice, Amount=100
// Name=Alice, Amount=50

Relational data: In EF Core, joins are automatic for navigation properties, but you can use explicit joins.

Example: LINQ Join documentation shows inner and left outer joins.