title: How to dynamic add filters to a LINQ query against an Odata Source in C#
body: <p>I have a query like the following</p>
  
  <pre><code>var query = (from x in NetworkDevices
  where   
  x.Name == "blabla1" ||
  x.Name == "blabla2" 
  select x );
  </code></pre>
  
  <p>and i'm running it against an Odata endpoint, so it effectively gets translated into the following URL</p>
  
  <pre><code>https://targetserver/endpoint.svc/NetworkDevices()?$filter=Name eq 'blabla1' or Name eq 'blabla2'
  </code></pre>
  
  <p>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.</p>
  
  <p>My Question, is in C# how do i dynamically add these filters to the where clause.</p>
  
  <p>in plain old LINQ (like linq 2 objects) i could do something like this.</p>
  
  <pre><code>var machines = new string[] { "blabla1" , "blabla2" } ;
  res1.Where ( x =&gt; machines.Contains(x.Name) ).ToArray()
  </code></pre>
  
  <p>and that would work, but that doesn't work against the Odata Endpoint as i get an error like this.</p>
  
  <p>The method 'Contains' is not supported</p>
  
  <p>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?</p>