How to use LINQ on a DataTable in Uipath

Viewed 14619

I am trying to filter a datatable using LINQ Query on Uipath and save the output as datatable format. Where col A has name and Col B has Price. I am trying to filter where price is greater than a value ( price>500) and save both Name and Price of filtered result to a datatable.

Please find the image which I am trying to do.LINQ Query from OutDT

3 Answers

d1.asEnumerable.where(Function(x1) CInt(x1("salary"))>500).copyToDatatable

or

d1.asEnumerable.where(Function(x1) x1("salary")>500).copyToDatatable if the salary column is already an integer

You may need to add Assembly reference as System.Data.DataSetExtensions if drop down does not appear after you type d1.asEnumerable.

You can also work in a function method approach to LINQ rather than a SQL-like syntax.

DT_Data = DT_Data.AsEnumerable.Where(
  Function(x) CINT(x("Price")) > 500
).CopyToDataTable

You can treat data in the DataTable with .Select(Func) Returning you a collection of however you treat the data.

Related