Feed a table from another datatable with linq

Hello all,

I have a data table called io_dt_Tabla with two columns named “ID” and “VR”. Then I have another dt called dt_GetVRid with two columns “REQUIREMENT” and “id”.

So, with “ID” and “number”, I need to put “id” in “VR”

This is what I am doing, but it is not working:

image

Assing:

image

PD: I need to do it by this way, because even I didn’t put it here, the first dt contains more columns that are going to filled in next steps doing the same procedure.

Thanks :slight_smile:

Hi @Angel_Llull_Rivero1

Does dt_GetVRid contains duplicate ID or the ID column has unique values only

Hi,

ID can contain duplicated values!

@Angel_Llull_Rivero1

You can convert the dt_GetVRid to a dictionary of key (number) and value (id)

image

(From row In dt_GetVRid
Group row By k=row("number").ToString.Trim.ToLower
Into grp=Group
Let tup = Tuple.Create(k, grp(0)("id").ToString)
Select tup
).ToDictionary(Function(k) k.Item1, Function(v) v.Item2)

Iterate through the rows of io_dt_Tabla to update the VR column

image

refer the attached xaml file

FeedWithLINQ.xaml (10.4 KB)