I am creating a generic form (C #) that can receive any Linq request. In this form, I want to be able to add filters (WHERE clauses). For operators like '=', '>', 'Like', etc., I can do things like IQueryable.Where(someFieldname + "> @0", someCriteria). But when I want to be able to make the equivalent of T-sql "IN", I am completely lost. I searched for a watch, but cannot find a way to figure it out.
When you think about how this is possible, you need to put the values ββfor the IN clause in a string array or some other simple list of strings. Then attach this list to the base query. But how can I join these two when the base request can be any request?
Example: Let's say my basic query looks something like this:
IQueryable<Object> q = from a in db.Adresses
select new { a.Street, a.HouseNr };
In the form I want to be able to filter on HouseNr as follows: Where HouseNr IN (1, 3, 5) Numbers (1, 3, 5) are available in an array of strings (or any other list of strings).
How can I achieve this, knowing that a basic query can be anything?
source
share