I want to build LINQ
, which will later be transferred WHERE IN
to sql
. In the normal case, I would do:
( querable
is IQuerable<T>
and arr
is IEnumerable<int>
)
querable = querable.Where(e => arr.Contains(e.Id));
BUT
My problem is that the value I want to filter ( e.Id
) is dynamic, and I get it as a string. How can i do this?
A little more background: I am making a REST API endpoint at which the user can send by which column he wants to filter the values, so examples will be:
What I want to translate into something like queryable.Where(e => new [] {1,2}.Contains(e.Id))
filter: {"customerId": [4,5]}
What I want to translate into something like queryable.Where(e => new [] {4,5}.Contains(e.CustomerId))
So basically my input is a column name, which is string
also a list of identifiers, whichIEnumerable<int>
, Expression
( ), , .