I need to use an expression for filtering Datatable. But in that expression, I would like to use variables.
Here is my expression:
(From p In dt.Select Where p(5).ToString.Equals(filtered_array(0).ToString) Or p(5).ToString.Equals(filtered_array(1).ToString) Select p).CopyToDataTable
I need to use variables because I need to build this expression based on an array, and I don’t know what is the length of an array. So I have in mind to build part of expressions based on an array and save it to variable
main_query = p(5).ToString.Equals(filtered_array(0).ToString) Or p(5).ToString.Equals(filtered_array(1).ToString)
And then filter datatable in Assign:
new_filtered_dt = (From p In dt.Select Where “+main_query.ToString+” Select p).CopyToDataTable
But when I tried to do that I got an error
Please, can somebody help me? Thanks!