There is a need to filter a certain data table and the filters might change so I wanted to use filter inputs as config values.
I was able to dynamically build the expression using AsEnumerable() as below example
SampleDT.AsEnumerable().Where(function(r) r("First Name").ToString = "John") OR r("First Name").ToString = "James").CopyToDataTable
the part r("First Name").ToString = "John") or r("First Name").ToString = "James") can be more if there are more filters but the expression gets built dynamically as a string .
the problem is, Iâm not able to assign this expression to a datatable type as a error at assign activity gives this
Cannot assign from type âSystem.Stringâ to type âSystem.DataTableâ in Assign activity
need help how I can assign this expression to a datatable type
For more clarity, Could you post a Screenshot of the Assign Activity in workflow, I do think you are trying to dynamically create a String Expression of the expression, which is not going to work.
We can manage this criteria using arrays, but we need more details on what exactly you mean by dynamic and what are the dynamic contents.
(From d in YourDataTableVar.AsEnumerable
Let check = arrFilterNames.Any(Function (x) d("First Name").ToString.toUpper.Trim.Equals(x.ToUpper))
Where check
Select r=d).CopyToDataTable
thanks for the reply.
yes Iâm trying to create a String Expression of the expression.
in the example the below is the example data table.
First Name
Last Name
John
L
James
K
Alex
P
Micheal
J
I need to filter First Name, some times it can be only John details I need to filter and some times its John, James details together I need to filter and sometimes its more
I need to filter have First Name as a config value so data filtration can be dynamic.