Update status through linq

Hi,

I want to update status where column (Number) is not equal to blank and the status is update in status column i.e. success.

I wanted to do this process through linq because I have lots of data
Book12.xlsx (10.3 KB)

LINQ isn’t faster than just using a For Each. It’s a myth.

Read Range to get the data into a datatable, For Each Row in Datatable and use an If to decide whether to update the value. Write back to the spreadsheet.

HI,

Hope the following sample helps you.

dt.AsEnumerable.Where(Function(r) Not String.IsNullOrEmpty(r("Number").ToString)).ToList.ForEach(
Sub(r)
    r("Status")="success"
End Sub
)

Sample20220908-6.zip (10.2 KB)

Regards,

I have lakhs of row

If i am using for each activity it will take lot of time i already try.

LINQ still has to loop, it just hides it from you. Everything loops. Tests have been done that show that LINQ isn’t faster than For Each.

Any solution for faster working

here you will get an overview to different options
How to Update Data Column Values of a Data Table | Community Blog

in your case it should be reacted on blank cells. So, the option of using Datacolumn.Expression can be checked. In contrast to updates with LINQ / For each… using the Expression has the benefit that it is a computed column value and also will be correct, when the row / number col will be updated afterwards

A lot of data is a lot of data. There’s no way around the fact that it takes time to process data.

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