While dealing with data table operations, sometimes we might want to retrieve only specific columns from it.
How to do that?
dt_New=dt_Original.DefaultView.toTable(false,”Column1″,”Column2″,…)
Note:
Simply replace the “Column1″,”Column2” and so on with your required Columns
Example
Implementation using UiPath :
Let us implement a workflow which takes a “DataTable” and gives us out the “DataTable with specific columns“.
Step 1:
Drag “Build Data Table” activity into the design panel and populate it with some sample data.
Step 2:
Drag “Assign” activity into the design panel and fill it with above-mentioned code.
Step 3:
Drag “Message Box” activity to display the result
(Note: Here we have used LINQ to display the DataTable Instead of Output DataTable
string.join(System.Environment.NewLine, dt_YourDataTable.Rows.Cast(of DataRow).Select(function(row) string.join(“,”,row.ItemArray))))
Step 3:
Finally!!!
Click here to download the Source Code…
Hope it has helped you…