title: Dynamic filtering using Linq
body: <p>I have a <code>List&lt;Device&gt;</code>. In the <code>Device</code> class there are 4 properties, namely <code>Name</code>, <code>OperatingSystem</code>, <code>Status</code> and <code>LastLoggedInUser</code>. I need to write a method:</p>
  
  <pre><code>IQueryable&lt;Device&gt; FilterDeviceList(
      List&lt;Device&gt; Devices,
      List&lt;string&gt; filter,
      string filterValue)
  </code></pre>
  
  <p>where <code>filter</code> will contain options for filtering <code>"name"</code>, <code>"os"</code> to indicate the fields to include in the search. If <code>"all"</code> is passed then all 4 fields need to be included.
  <code>filtervalue</code> will contain the value to be filtered like <code>"windows"</code>, <code>"Calvin"</code>.</p>
  
  <p>Can anyone suggest a method to achieve this?</p>
  
  <p>Edit:</p>
  
  <p>If I was not clear, I am doing the filtering somewhat like this, it is the commented part for which I need the code.</p>
  
  <pre><code>if(filter.contains(name))
  {
  //filter with name
  }
  if( filter.contains(both name and os)
  {
  // I only need the filter value to contain in name or OS (only needed in any one of the field,not necessary to be in both)
  
  }`
  </code></pre>