I was wondering if it is possible to dynamically create LINQ queries during runtime.
The idea is to let the user decide in which way to filter a datatable, without changing code in the bot.
Ideally I’d use an Excel file as config (or maybe a UiPath Form) which has the same format as the Filter Wizard from the
Filter Data Table Activity.
The user can then create the filter he likes and run the bot.
The bot will parse the config and create a LINQ query.
For this example the query would look like this:
(From row In dtTest.AsEnumerable Where row("Name").ToString.StartsWith("A") AndAlso Cint(row("Age").ToString) > 18 AndAlso row("Occupation").ToString.Contains("consultant") Select row).CopyToDataTable
As this always has a fixed format I think I can build this string with some basic string manipulation.
My big problem is: How to make this executable?
I will have a string variable with a valid LINQ query, but I have no idea how to actually execute this or use this in an assign activity.
It’s possible when using an SQL query with an SQL DB, but in my case I need this to work with datatables.
Do you have any ideas on how to solve this?