2

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

Supriyo404
  • 23
  • 1
  • 1
  • 5
  • 1
    Please post code as text. Images can't be used for copying into answers and they won't appear in search engine results. That said, also make sure there's enough information in your question to make it answerable. And... what's the actual question? – Gert Arnold Aug 08 '20 at 21:29
  • See: [How to Filter Data Tables in UiPath Studio](https://www.uipath.com/community/rpa-community-blog/four-ways-to-filter-data-table-in-uipath-studio) – iRon Aug 09 '20 at 10:34
  • I don't have an exact answer for you but when in doubt on how to do anything in UiPath using code, just remember it's accepts regular VB.NET. This should make searching a bit easier. – Tudor Carean Aug 12 '20 at 14:47

3 Answers3

2

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.

AnkitKwar
  • 76
  • 9
0

Filter with LINQ:

(From row In YourDataTable.AsEnumerable Where CInt(row("price").ToString) > 500 Select row).CopyToDataTable

If you found error message:

AsEnumerable is not a member of 'System.Data.Datatable'

Please add reference below to your xaml file.

<AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>

Reference: https://forum.uipath.com/t/asenumerable-is-not-a-member-of-system-data-datatable/69198/2?u=akkapolk

akkapolk
  • 554
  • 8
  • 33
0

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.

Argeno
  • 11
  • 1