Is there a way, to merge two dataTables table1 and table2 by different keys?
Want to do dataTable.Merge by t1 PK_id and t2 ParentId. Is this possible if ParentId is not a PK?
table1
PK_id Name
--------------
1 test1
2 test2
3 test3
table2
PK_id2 ShortName ParentId
---------------------------
1 a 1
2 b 1
3 c 2
Result is a right join
PK_id Name PK_id2 ShortName ParentId
------------------------------------------------
1 test1 1 a 1
1 test1 2 b 1
2 test2 3 c 2
3 test3 null null null
Thanks in advance.
Using linq will probably be your best bet. There will be some extra things you’ll have to add to your code but this example does a really nice job of explaining it.
http://support.microsoft.com/kb/326080/en-us