I have a query like the following
var query = (from x in NetworkDevices
where
x.Name == "blabla1" ||
x.Name == "blabla2"
select x );
and i'm running it against an Odata endpoint, so it effectively gets translated into the following URL
https://targetserver/endpoint.svc/NetworkDevices()?$filter=Name eq 'blabla1' or Name eq 'blabla2'
So i want to dynamically add lots of those where filters... In C# i can just keep adding it to my query, but that isn't dynamic. I want to do it at runtime. If i was calling this from Javascript, well i can easily just update the URL as well.
My Question, is in C# how do i dynamically add these filters to the where clause.
in plain old LINQ (like linq 2 objects) i could do something like this.
var machines = new string[] { "blabla1" , "blabla2" } ;
res1.Where ( x => machines.Contains(x.Name) ).ToArray()
and that would work, but that doesn't work against the Odata Endpoint as i get an error like this.
The method 'Contains' is not supported
So i presume the only way would be to dynamically , edit the expression tree or something to add those filters. Does anybody know how to do that?