Linq queries for join/look up datatable


Please refer the sample input datatable1 and datatable2, Can you please help me with joining them or looking up city value in datatable2 with the help of linq queries?
Please refer the output datatable.
Thanks in advance.

@Tanmay_V_Chetule

create dictionary variable for the datatable2

dt2.AsEnumerable.ToDictionary(Function(x) x(0).ToString.Trim,function(x) x(1).ToString.Trim)

use add datacolumn activity for datatable1

later use another assign activity

dt2.AsEnumerable.Select(Function(a) dt2.Clone.LoadDataRow({a(0).ToString,a(1).ToString,dict_Cityvalues(a(1).ToString.Trim)},False)).CopyToDataTable

hope this helps

failing at the last assign activity, Given key not present in the dictionary. Everything seems to be correct in the dictionary too.

Just to make sure, you know there is a Join Data Table activity, right? Makes it very simple.

@Tanmay_V_Chetule

you need to use add datacolumn activity for datatable 1

dt1.AsEnumerable.Select(Function(a) dt1.Clone.LoadDataRow({a(0).ToString,a(1).ToString,dict_Cityvalues(a(1).ToString.Trim)},False)).CopyToDataTable

use the above query once

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.