Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / OpenAccess ORM > OpenAccess ORM Free Edition > LINQ - LEFT JOIN

Not answered LINQ - LEFT JOIN

Feed from this thread
  • Neagoe avatar

    Posted on Mar 15, 2011 (permalink)

    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

    Reply

  • Petko_I Petko_I admin's avatar

    Posted on Mar 21, 2011 (permalink)

    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

    Reply

  • Karlo avatar

    Posted on Feb 8, 2012 (permalink)

    Hi Petko_I,

    How can your solution be done when using openaccesslinqdatasource?

    Reply

  • Damyan Bogoev Damyan Bogoev admin's avatar

    Posted on Feb 10, 2012 (permalink)

    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. 
    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / OpenAccess ORM > OpenAccess ORM Free Edition > LINQ - LEFT JOIN