This is a migrated thread and some comments may be shown as answers.

LINQ - LEFT JOIN

3 Answers 165 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Neagoe
Top achievements
Rank 1
Neagoe asked on 16 Mar 2011, 02:33 AM
var Query = from antete_facturi in ZdbContext.AnteteFacturis
                        join adrese_livrare in ZdbContext.AdreseLivrares on new { Idadresalivrare = antete_facturi.IdAdresaLivrare } equals new { Idadresalivrare = adrese_livrare.Id } into adrese_livrare_join
                        from adrese_livrare in adrese_livrare_join.DefaultIfEmpty()
                        select new
                        {
                            Adresalivrare = adrese_livrare.AdresaLivrare,
                            antete_facturi.IdPartener,
                            antete_facturi.NrFactura,
                            antete_facturi.DataFactura
                        };

Previous linq query work perfect in dbml model, in OA result is null.
I try to do an evaluation of the product before I buy it, if you have a suggestion to the above problem, please post a reply.
Best regards,
   Adrian Neagoe

3 Answers, 1 is accepted

Sort by
0
Petko_I
Telerik team
answered on 21 Mar 2011, 08:59 PM
Hello Neagoe,

Unfortunately, this LINQ scenario with DefaultIfEmpty() is not fully supported yet by OpenAccess. We are working towards improving our LINQ support and this scenario will be one of the first things that we will address. A workaround would be to retrieve the matching joined records in one query and invoke a second query to retrieve the hanging records from the left outer join. Let's consider the following example - we have Orders served by Employees and not every employee has served an order. To get those employees we may first find the rest of the employees who have participated in an order and exclude them from the overall set of the employees:
IList<int?> employeeServedOrders = context.Orders.Select(x => x.EmployeeID).Distinct().ToList();
var query = from employee in context.Employees
         where !employeeServedOrders.Contains(employee.EmployeeID)
         select employee;

We do hope you will find the provided information useful. We will be working on making your example running without extra queries. Should you have further questions, feel free to contact us.

Best wishes,
Petko_I
the Telerik team
0
Karlo
Top achievements
Rank 1
answered on 08 Feb 2012, 06:24 AM
Hi Petko_I,

How can your solution be done when using openaccesslinqdatasource?
0
Damyan Bogoev
Telerik team
answered on 10 Feb 2012, 03:33 PM

Hello Karlo,

I have prepared a sample application which demonstrates how to achieve that goal using OpenAccessLInqDataSource.
Hope that helps.

All the best,
Damyan Bogoev
the Telerik team
Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
Tags
Data Access Free Edition
Asked by
Neagoe
Top achievements
Rank 1
Answers by
Petko_I
Telerik team
Karlo
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or