Results 1 to 5 of 5

Thread: how to use LINQ to left join 2 datatables

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2007
    Posts
    64

    how to use LINQ to left join 2 datatables

    Hello,

    I have two UNTYPED datatables: "Shelfs" and "Books". Data came from different databases.

    I must create a "left join" relationship because I want a list of ALL shelfs and books (if they have any).

    Code:
    Dim dset As New DataSet
    
    dset.Tables.Add(dtShelfs)
    dset.Tables.Add(dtBooks)
    
    dset.Relations.Add("Shelfs", dset.Tables("dtShelfs").Columns("shelfID"), dset.Tables("dtBooks").Columns("shelfUsed"), False)
    Basic question: I can I do this, using LINQ? I want the result on a new datatable...

    I spent hours googling around, but all examples I found were only applicable to strongly typed dataSets, and how to build queries (not to get the data)

    I could solve this the "easy" way: by looping both datatables and sending the rows to a third one, but I want to do this the "right" way and, of course... LINQ exists to make things easier and I don't know how to use it

    Thanks!
    Last edited by Javo2004; Nov 10th, 2011 at 12:35 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width