How ‘Outer join’ changed in Linq?
One of the most frequently asked query type is outer join. With T-Sql by using ‘left outer join’ type it was possible to get the records of the Customer table without the orders.
T-Sql usage:
select c.ContactName, OrderID= case when o.OrderID is null then ‘(no orders)’ else convert(varchar,o.OrderID) end
from Customers c
left outer join Orders o on o.CustomerID = c.CustomerID
With Linq type instead of “outer” sentence, “DefaultIfEmpty()” method is used to get “left outer join”.
The usage of the T-Sql query above in Linq type:
DataClassesDataContext db = new DataClassesDataContext();
var Cust = from c in db.Customers
join o in db.Orders on c.CustomerID equals o.CustomerID into g
from o in g.DefaultIfEmpty()
select new {c.ContactName, OrderNumber = o == null ? “(no orders)” : o.OrderID.ToString() };

hello!
does anybody know how i can do a join and then, making an update for that join?
Comment by geli — July 16, 2008@ 1:08 pm