left outer joins
LINQ
3
Posts
3
Posters
2
Views
1
Watching
-
Left outer joins are created using Group Join and the DefaultIfEmpty() Lets say I want all customers and any OrderIDs (even if customer has no orders). Using Northwind datacontext in db:
Dim query = From c In db.Customers _
Group Join o in db.Orders _
On c.CustomerID Equals o.CustomerID _
Into tmp = Group _
From t in tmp.DefaultIfEmpty _
Select New With { _
.Name = c.CompanyName, _
.OrderID =If(t is Nothing, _
"** no order **", _
CStr(t.OrderID)) }The group join creates a list of the orders for each customer. DefaultIfEmpty specifies the outer-join part. This is will return '** no order **' if a customer has no orders, otherwise one row per order. Check out this article[^] for more help.
'Howard
-
like sql s server