How to Update status column of Datatable after filtering some rows

Hello friends
I have one datatable. first im filtering some lines out of 100 lines based on some condition and performing some operation.

After the operation is performed i have to update all filtered lines as failed or success in the same data table . I can do this by for each but it takes more time, is there any faster way to do it.

Thanks in advance…

@aslam_ali1

you can use LINQ to update the rows:


DT.AsEnumerable().Where(Function(row) 'Your condition here').ToList().ForEach(Sub(row) row("Status") = "Success")

DT.AsEnumerable().Where(Function(row) Not 'Your condition here').ToList().ForEach(Sub(row) row("Status") = "Failed")
1 Like

Use a assign activity and have this one linq query to update ur column value for all rows using linq

dt = dt.AsEnumerable().ToList().ForEach( Sub(row) row("Status") = If('Your condition here', "Success", "Failed") End Sub)

U can a replace the text Your condition here like

row(“yourcolumnname”) = “this value”

For more such Datatable functionalities
Refer this

Hope this helps

Cheers @aslam_ali1

Hi @aslam_ali1,

Please use linq for faster processing.

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