Updating values for duplicate item in a excel using LINQ

in general, we would recommend combining LINQ and essential activities like:

Groups | List(of List(of DataRow)) =

(From d In dtData.AsEnumerable
Group d By k=d(1) Into grp=Group
Select g = grp.toList).toList

for the update, we can prepare e.g. a dictionary, where the key is a group key like

new Dictionary(Of String, String) From {{“Amazon”,"…},…}
and can use it as
mrow(0) = dictLK(mrow(1).toString)

We used this technique also on huge data volumes and it was executed fast enough. In rare cases, we switched to Parallel For each for the group processing (outer loop)

Also we would implement some logic handling non present keys in the LookUp Dictionary

With the payoff of DataTable reconstruction and Blackboxing a prototype LINQ maybe also can be formulated.

But critical checking the case it is similar to a

  • A: update all rows first col depending on rows second col value
  • B: update filtered rows first col depending on rows second col value

where case A can be done in a for each along with this dictLK approach
where case B can be done on the filtered datatable row set with a variable

Also have a look here: