In terms of improving DA LINQ, I’m happy to announce that i have just committed improved support for the LEFT OUTER JOIN in the next release of the Data Abstract for .NET.
We can compose Left Outer join query by using DefaultIfEmpty standard query operator. See the sample below:
var query =from c in lrda.GetTable()where c.CustomerID=="PARIS"join o in lrda.GetTable() on c.CustomerID equals o.CustomerIDinto ords from o in ords.DefaultIfEmpty()selectnew{c.CustomerID, o.EmployeeID}; |
The DA LINQ query above will be translated into following DA SQL statement that will be passed to the DASqlengine.
SELECT[t0].[CustomerID],[t1].[EmployeeID]FROM[Customers]AS[t0]LEFTOUTERJOIN[Orders]AS[t1]ON([t1].[CustomerID]=[t0].[CustomerID])WHERE([t0].[CustomerID]= :p0)--- :p0='PARIS' |
and it will execute against the database with the expected result:
CustomerID EmployeeID ---------- ----------- PARIS NULL |