title: How can I cast an expression from type interface, to an specific type
body: <p>In my interface I have following defined</p>
  
  <pre><code>List&lt;IFoo&gt; GetListOfFoo&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; predicate) where T : IFoo;
  </code></pre>
  
  <p>In my implementation I'll cast the expression in the specific type:</p>
  
  <pre><code>if (typeof(T) == typeof(Foo))
  {
      Expression converted = Expression.Convert(predicate.Body, typeof(Foo));
      Expression&lt;Func&lt;Foo, bool&gt;&gt; newPredicate = 
          Expression.Lambda&lt;Func&lt;Foo, bool&gt;&gt;(converted, predicate.Parameters);
  }
  </code></pre>
  
  <p>I try to use my implementation like this:</p>
  
  <pre><code>Expression&lt;Func&lt;Foo, bool&gt;&gt; predicate = c =&gt; c.Name == "Myname";
  _repository.GetListOfFoo&lt;Foo&gt;(predicate);
  </code></pre>
  
  <p>I get no compiling errors, but if I use this, I get an Exception that in the ExpressionBody is the bool argument defined. </p>
  
  <p>Where is my problem?</p>