title: How to use an expression with a generic func lambda in a linq where clause?
body: <p>Here's what I have</p>
  
  <pre><code>private readonly Dictionary&lt;Type, List&lt;object&gt;&gt; _cache;
  
  public IList&lt;T&gt; Get&lt;T&gt; (Expression&lt;Func&lt;T, bool&gt;&gt; criteria)
  {
      return _cache[typeof(T)].Where (criteria);
  }
  </code></pre>
  
  <p>The compiler complains (rightly) that it cannot convert from object to T.</p>
  
  <p>How should I proceed from there?</p>
  
  <hr>
  
  <h2>Solution</h2>
  
  <pre><code>return _cached[type].AsQueryable().Cast&lt;T&gt;().Where (criteria).ToList()
  </code></pre>
  
  <p>The idea is to have the List as an IQueryable and then I could Cast...</p>