Linq - Update Values in Datatable

Hey,
I have 2 different type of changes that I need to do on a datatable

  1. Update all specific column values to new value, for example
    the original datatable
    A B C
    1 3
    2 4

the new datatable
A B C
1 3 OK
2 4 OK

  1. Update column value when the value contain 2 different type of string (I cant use equal), for example if the value in column ‘C’ contain ‘OK’ or contain Value’ to update those row(‘C’) to ‘Done’

I work on big datatable - over 50k rows so I understand the work with linq will be more efficient and fast than work with For Each and Assign

@noam
find a starter help here:
Update_StatusCol.xaml (6.9 KB)

Not all requirements were clear to me but the demo xaml shows the general building blocks on how similar tasks can be handled.

Let us know your feedback

@ppr tnx for your quick help!

I try to be more clear, my datatable have over 50k rows and over 20 columns.
I’m looking for 2 queries
1.update new value for all rows in a specific column - for example update all the values in column number 4 (no matter what was the old value) to new value
2. query that update all the rows if specific column contain 2 different type of values (for example, if column number 3 contain “work” and “done” then replace it to"work done" - sometimes we receive in this column a symbol instead space like “work@done” or “work&done” so we looking for a query that correct those mistakes)

@noam

1.update new value for all rows in a specific column - for example update all the values in column number 4 (no matter what was the old value) to new value

You can play on provided xaml with following (Col 3 is updated with NewValue String)

(From d In dtData.AsEnumerable
Let ra= New Object(){d(0),d(1),“NewValue”}
Select dtResult.Rows.Add(ra)).CopyToDataTable

for second request have a look here:
Reset_StatusCol_MultiContains_KwordList.xaml (8.0 KB)

@ppr

tnx again, Its work.

  1. How can i adjust it to my datatable with 20 columns?
  2. There is an option use the original datatable and not to open a new datatable? (in you xaml - not to add row to dtResult, only update dtData)

@noam
LINQ is about retrieval and updating is stressing the concept of LINQ
all update methods e.g. setField are subs, doesnt return a value and canot be used in LINQ within an assign
in some cases update statements can be written by using invoke code

Having this in mind is giving the reason why it is worked with constructing itemarray and add rows to the empty cloned datatable