Outer Join

6 posts, 0 answers
  1. Nader
    Nader avatar
    4 posts
    Member since:
    Oct 2014

    Posted 25 Feb 2015 Link to this post

    I must be missing something simple.  I'm trying to do a Left or Right Outer Join using LINQ but it doesn't seem to work with Data Access:

    Dim myFields As IEnumerable(Of LibFieldNameValues) = (From c In dbContextLib.LibItemFields
                                                            Join d In dbContextLib.LibItemFieldOptions On c.ItemFieldID Equals d.ItemFieldID
                                                            Join q In dbContextItem.ItemDetails On d.ItemFieldOptionID Equals q.ItemFieldOptionID Into t
                                                            From q In t.DefaultIfEmpty()
                                                            Where d.CommodityID = CommodityID And q.ItemID = ItemID
                                                            Select New LibFieldNameValues With {.FieldName = c.FieldName,
                                                                                                .FieldValue = q.OptionValue})

    It does not like the "Into" lines.

    Any help would be appreciated. 

    Thanks,
    ND












  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 02 Mar 2015 Link to this post

    Hello ND,

    without looking too deep into this I could imagine that the issue lies in the double usage of the q variable. Please rename the q in the Into line to something else and change the following projection accordingly. That should get you around this issue.

    Regards,
    Thomas
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. Nader
    Nader avatar
    4 posts
    Member since:
    Oct 2014

    Posted 19 Mar 2015 in reply to Thomas Link to this post

    Dim tmp = (From c In dbContext.ISNs
    Join d In dbContext.ISNShipments On c.IsnID Equals d.IsnID Into T
    From G In T.DefaultIfEmpty()
    Select G)

    I must be doing something wrong.  Can this type of query even be done with Telerik Data Access?
  5. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 20 Mar 2015 Link to this post

    Hi ND,

    this query looks perfectly legal to me and should produce a left outer join.

    Regards,
    Thomas
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  6. Nader
    Nader avatar
    4 posts
    Member since:
    Oct 2014

    Posted 20 Mar 2015 in reply to Thomas Link to this post

    For some reason Visual Studio doesn't like the:

    Into T
    From G In T.DefaultIfEmpty()

    And it does not compile.
  7. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 24 Mar 2015 Link to this post

    Hi Nader,


    please use the correct VB syntax there:

    ...
    Group Join q In Scope.Extent(Of Northwind.OrderDetail)() On d.Id Equals q.OrderID Into t = Group _
    From G In t ...


    Regards,
    Thomas
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
Back to Top
DevCraft banner