I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax.
T-SQL
SELECT
o.OrderNumber,
v.VendorName,
s.StatusName
FROM
Orders o
LEFT OUTER JOIN Vendors v ON
v.Id = o.VendorId
LEFT OUTER JOIN Status s ON
s.Id = o.StatusId
WHERE
o.OrderNumber >= 100000 AND
o.OrderNumber <= 200000
Don't have access to VisualStudio (I'm on my Mac), but using the information from http://bhaidar.net/cs/archive/2007/08/01/left-outer-join-in-linq-to-sql.aspx it looks like you may be able to do something like this:
This may be cleaner (you dont need all the
into
statements):Here is another left join example
In VB.NET using Function,
I think you should be able to follow the method used in this post. It looks really ugly, but I would think you could do it twice and get the result you want.
I wonder if this is actually a case where you'd be better off using
DataContext.ExecuteCommand(...)
instead of converting to linq.I am using this linq query for my application. if this match your requirement you can refer this. here i have joined(Left outer join) with 3 tables.
I figured out how to use multiple left outer joins in VB.NET using LINQ to SQL: