DataSets do not have access to the .Join() method as most collections in LINQ sadly. It does feature a .Merge() method which might be exactly what you are
looking for as long as the two datasets share the same schema.
The third party option looks fun! Can't use it as an option though.
I'll keep searchin away. I don't need an easy solution necessarily. I would happily take a more involved route if I had someone to explain in detail how to implement it.
artvindustri...
Member
14 Points
52 Posts
Joining 2 DataSets with a Primary Key
Jan 15, 2013 08:16 PM|LINK
Hello all,
I have 2 datasets from 2 different Web Services and reading them into DataSets:
DataSet dsLoans = new DataSet();
dsLoans.ReadXml(XmlReader.Create(new StringReader(myWLSreference.GetCustomLoanExport2())));
DataSet dsCompany = new DataSet();
dsCompany.ReadXml(XmlReader.Create(new StringReader(myWLSreference.GetCustomCompanyExport2())));
Should I use a primary key to join these DataSets? If so, the PrimaryKey intellisense isn't popping up in my List Method. :(
Rion William...
All-Star
27114 Points
4492 Posts
Re: Joining 2 DataSets with a Primary Key
Jan 15, 2013 08:19 PM|LINK
DataSets do not have access to the .Join() method as most collections in LINQ sadly. It does feature a .Merge() method which might be exactly what you are looking for as long as the two datasets share the same schema.
Usage :
artvindustri...
Member
14 Points
52 Posts
Re: Joining 2 DataSets with a Primary Key
Jan 15, 2013 09:40 PM|LINK
If by same schema you are referring to the table structure then no.
Table1 is:
<loan>
<oID>blah</oID> //this is the key i would use to join
<oAcct>blah</oAcct>
</loan>
Table 2 is:
<company>
<cID>blah</cID> //this is the key i would use to join
<cNamet>blah</cName>
</company>
Can I create a relationship with Merge somehow?
Rion William...
All-Star
27114 Points
4492 Posts
Re: Joining 2 DataSets with a Primary Key
Jan 15, 2013 10:00 PM|LINK
This link might be exactly what you are looking for :
Joining Datasets using LINQ
(Hopefully it's a step in the right direction at least)
artvindustri...
Member
14 Points
52 Posts
Re: Joining 2 DataSets with a Primary Key
Jan 16, 2013 04:52 PM|LINK
Thanks for all your feedback Rion.
Unfortunatley I still haven't been able to Google my problem away. :(
I thought I was close this this solution:
http://forums.asp.net/t/1708173.aspx/1?how+can+i+inner+join+tables+within+DATASET+
Rion William...
All-Star
27114 Points
4492 Posts
Re: Joining 2 DataSets with a Primary Key
Jan 16, 2013 04:58 PM|LINK
Sorry that you couldn't find an "easy" solution. Here are a few more that might be worth trying (although I am sure you have seen most of them before)
Inner Joining DataTables in C#
Inner Joining DataTable through a Primary Key
If you are willing to consider a third-party option - you may want to consider looking at QueryADataSet's library for performing SQL operations on DataSets in C#.
artvindustri...
Member
14 Points
52 Posts
Re: Joining 2 DataSets with a Primary Key
Jan 16, 2013 05:10 PM|LINK
The third party option looks fun! Can't use it as an option though.
I'll keep searchin away. I don't need an easy solution necessarily. I would happily take a more involved route if I had someone to explain in detail how to implement it.