//// Query Syntax var result = from c in customers join o in orders on c.CustomerID equals o.CustomerID selectnew { CustomerName = c.Name, OrderID = o.OrderID, OrderDate = o.Date };
//// Method Syntax var result = customers.Join( orders, c => c.CustomerID, o => o.CustomerID, (c, o) => new { CustomerName = c.Name, OrderID = o.OrderID, OrderDate = o.Date } );
//// Query Syntax var result = from c in Customers join o in Orders on c.CustomerID equals o.CustomerID join p in Products on o.ProductID equals p.ProductID selectnew { c.Name, o.OrderID, p.ProductName };
//// Method Syntax var result = Customers.Join( Orders, c => c.CustomerID, o => o.CustomerID, (c, o) => new { c, o } ).Join( Products, co => co.o.ProductID, p => p.ProductID, (co, p) => new { co.c.Name, co.o.OrderID, p.ProductName } );
//// Query Syntax var result = from c in Customers join o in Orders on c.CustomerID equals o.CustomerID into customerOrders from o in customerOrders.DefaultIfEmpty() selectnew { c.Name, OrderID = o?.OrderID ?? 0 };
//// Method Syntax var result = Customers.GroupJoin( Orders, c => c.CustomerID, o => o.CustomerID, (c, customerOrders) => new { c, customerOrders } ).SelectMany( co => co.customerOrders.DefaultIfEmpty(), (co, o) => new { co.c.Name, OrderID = o?.OrderID ?? 0 } );
//// Query Syntax var querySyntax = from character in characters let experienceToNextLevel = GetExperienceToNextLevel(character.Level, character.Experience) where character.Level >= 5 orderby experienceToNextLevel ascending selectnew { character.Name, ExperienceToNextLevel = experienceToNextLevel };