Linq Query Instead Of For Each Loop

Hi All,

I want to loop through three columns in excel sheet .(internal_id, mismatched_column, sdfc_RPA). If I dont want to use for each loop in datatable, how to use linq to loop through these columns .

@Anil_G any suggestion on this

Hi @marina.dutta

Do you want to filter the rows based on the conditions. Then give us a detailed conditions then only we can give the LINQ Expression.

Hope you understand!!

Hi @marina.dutta

If you want only 3 columns try the below

DT.DefaultView.ToTable(False,{"Columnname1", "Columnname2", "Columnname3"})

Cheers!!

@mkankatala

I already filtered the datatable by column mismatched =0, sdfc_RPA=true. Now I want to apply for each row and pick up each internal id and search in application.

My original Columns were


After filtering


Now I want to loop through entire filtered data table and pick each internal_id column value and search in application. For example first internal_id after filter will be 1196780. Similarly I want to pick all the internal ids instead of using for each as I am having 333 internal ids. Using for each for 363 times will consume a lot of time. How can I avoid for each and use linq to loop through entire filtered data table and pick up column B values and search one by one in application

For your condition you don’t have option to use LINQ Expression, we recommend you to use for each row in datatable activity to iterate the each row and get each internal ID.

LINQ Expression works in such scenarios like it will filter the rows in input datatable and store the filter rows in the output datatable and store whole column values in a list or array.

But in your case, LINQ not works. LINQ is a expression only you can use it in assign activity but you can’t iterate through each row.

Hope you understand!!

@marina.dutta

Linq is to process your data but not to unterqct with external application…that anyways needs to be done in loop

If there is a way to seqrch multiple at once then we cna use linq

Cheers

2 Likes

@Anil_G

So that means if there are 363 internal ids to search , my loop needs to run 363 times. That would be very time consuming . Anyways if there is no option then I have to follow the for each loop .

@dutta.marina

Yes because that is hiw you search right

Cheers

1 Like

No matter what you do, you have to loop and do some steps in the application. Those steps are the time consuming part, not the loop. It doesn’t matter what method you choose, you’re performing 300+ searches in an app and that is going to take time. Automations take time. You can’t just get around it.

2 Likes

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