banner



What .net Method Of The Datatable Object Can Be Used To Filter A Table By A Condition?

⬅  Run across ALL THE Articles

Those who take just started the UiPath journey know quite well how important Data Table is while working with UiPath Studio. Every bit important are operations we perform on Data Tabular array to get a desired effect.

Studio has a very cool and handy activity for filtering Data Tables. At the same fourth dimension, at that place are some quick means in which y'all tin filter information even if yous practise not have coding experience. Once you get-go using Data Tables, yous will apace get used to them.

Then, let's showtime with the first cool option: the default filter Information Tabular array activeness for Studio. Suppose we have a table with 10 records with columns similar FirstName, LastName, Visitor, Address, etc. For this example, I desire to filter the records based anyone with the first name as "John." We will use this instance throughout this tutorial post, with different approaches.

I take already read an Excel and put the data into SampleDT variable and FilteredDT is the variable that we will use for storing the result.

1-621

Filter Data Table activity in Studio

Drag the action into your pane. When you click on Filter Wizard, you tin can see the Wizard. Just add together Input and Output table names and the atmospheric condition. You are done. 😊 You can have multiple conditions and add or remove rows based on condition.

2-18

You can also cull what columns you want as a result, by adding columns via the Output Columns tab. That's it. Wow how piece of cake was that?

McDowel Digital Media, Inc. (8)

DataTable.Select() method

At present, this is another method which is very elementary, short, and sweet 😊. With the DataTable.Select() method, you tin directly assign filter rows to an array or data table using this expression. Create a type variable, either DataTable or DataRow [], that is an array of Data Rows. Past default, this method returns the array of information rows only you lot tin convert information technology at whatever time to a Data Table.

I take created a DataTable variable FilteredDT  and you can write the expression like this:

4-10

You are washed 😊. Once again, simple.

3-8

DataTable extension method DataTable.AsEnumerable()

For this method, we will assign the filtered data in the same DataTable variable FilteredDT. This method, by default, returns IEnumerable where T is DataRow. Merely write the expression as below:

6-10

Look how fast and like shooting fish in a barrel was that!

4-11

Filter with LINQ

Those who are comfy with C# or Visual Basic.NET (VB.NET) volition love using this method. This returns IEnumerbale by default, just every bit I mentioned earlier, it tin be converted into a DataTable. See the expression:

5-10

While using extension methods and LINQ for DataTable, the example above looks very simple for basic filtration. Merely, you can also write circuitous queries using this. In terms of performance, these two are much faster than others.

You volition not exist able to see any functioning deviation in 100 records, only if you have more than x,000 records, yous will notice a handsome performance by these ii methods.

Working with Information Table is a very of import part of your automations. These methods will help y'all do it in a better and dissimilar way. Meanwhile, you lot tin can wait on UiPath Forum and Uipath Go! to explore more about this and other activities.

The more you play with Studio and activities, the more heady and easier information technology will exist! Happy automating!

register uipath devcon 2021

Prankur Joshiis a freelance RPA developer.


What .net Method Of The Datatable Object Can Be Used To Filter A Table By A Condition?,

Source: https://www.uipath.com/community/rpa-community-blog/four-ways-to-filter-data-table-in-uipath-studio#:~:text=DataTable.Select()%20method&text=With%20the%20DataTable.,data%20table%20using%20this%20expression.

Posted by: galazmagentleed80.blogspot.com

0 Response to "What .net Method Of The Datatable Object Can Be Used To Filter A Table By A Condition?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel