Trying to generate the following SQL from Linq-To-Sql
SELECT
parenttableA.Name AS parentA,
childtableA.Name AS childA,
parenttableB.Name AS parentB,
childtableB.Name AS childB
FROM parenttableA
INNER JOIN childtableA ON childtableA.parentid = parenttableA.id
LEFT OUTER JOIN
(
parenttableB
INNER JOIN childtableB ON childtableB.parentid = parenttableB.id
)
ON parenttableB.townid = parenttableA.townid
WHERE parenttableA.townid = 123
This SQL should return something like:
parentA childA parentB childB
======= ====== ======= ======
John Dave Paul Mark
Jim John (null) (null)
So, in other words:
How can I have 2 separate inner joins linked together with a LEFT OUTER JOIN so that I still get "A" records from town 123, even if no "B" records exist for that town?