Linq Compare 2 DataTable and Get Some Value from other DataTable

maybe on the first look, when the lookup is not modelled in an cost processing saving approach

we encourage to have trained all presented options:
How to Update Data Column Values of a Data Table | Community Blog

And also have understood:

  • avoiding black-boxing when using LINQ
  • the pay-off of DataTable reconstructions

have a look here, on how we tuned:

Assumptions: no duplicates IDs within dt1,dt2

Similar you can build a lookUp Dictionary, where ID is the key
Assign Activity:
dictLK | Dictionary(Of String, Object() ) =

(From d in dt2.AsEnumerable
Let oa = {"Col1Name","Col2Name","Col3Name"}.Select(Function (cn) d(cn)).toArray
Select t = Tuple.Create(d("ID").toString.Trim, oa)).ToDictionary(Function (t).t.Item1,Function (t).t.Item2)

Now we can loop / parallel loop over dt1

  • check if dictLK.Contains(“TheLoopedDt1IFValue”)
  • And update the cols