title: How do I filter a strongly typed list with List<String> variables
body: <p>I need to filter a strongly typed list of type StaffingPositionsDataContract, with another list of filter names and values.  I have these two lists: </p>
  
  <pre><code>    List&lt;SerializedForm&gt; deserializedObject = JsonConvert.DeserializeObject&lt;List&lt;SerializedForm&gt;&gt;(searchFilters).Where(x =&gt; !string.IsNullOrEmpty(x.value) &amp;&amp; !string.Equals(x.value.ToUpper(), "ALL")).ToList();
      List&lt;StaffingPositionsDataContract&gt; staffingPositionResponse = new StaffingPositionsDataContract().LoadMockData();
  </code></pre>
  
  <p>The deserializedObject has 2 properties.  1: "name", 2: "value".  These properties need to be able to filter several different classes with different properties.  I have a method that works if the StaffingPositionsDataContract currently being filtered is a string, but not int or decimal or float. Below is what I am using that works with string filters only.</p>
  
  <pre><code>  private static List&lt;T&gt; _GetFilteredList&lt;T, U&gt;(IList&lt;T&gt; ListToFilter, string PropertyToFilterOn, List&lt;U&gt; FilterValues)
      {
          ParameterExpression p = Expression.Parameter(typeof(T), "x");
  
          Func&lt;T, U&gt; select = Expression.Lambda&lt;Func&lt;T, U&gt;&gt;(
              Expression.Property(p, PropertyToFilterOn), p).Compile();
  
          return ListToFilter.Join(FilterValues, select, u =&gt; u, (t, u) =&gt; t).ToList();
      }
  </code></pre>
  
  <p>Here is how that is getting called:</p>
  
  <pre><code> var filteredPositions = staffingPositionResponse;
          deserializedObject.ForEach(delegate(SerializedForm filters)
          {
              filteredPositions = _GetFilteredList&lt;StaffingPositionsDataContract, string&gt;(staffingPositionResponse, filters.name, new List&lt;string&gt; { filters.value });
          });
  </code></pre>
  
  <p>Anyone know how I can filter the staffingPositionResponse class with the deserializedObject objects?  </p>