title: Unable to cast object exception while using LINQ To Entities with LINQKit
body: <p>I'm using <strong><a href="http://www.albahari.com/nutshell/linqkit.aspx" rel="nofollow">LINQKit</a></strong> to expand LINQ To Entities capabilities: </p>
  
  <pre><code>public Boolean IsMatched(Int32 age)
  {
      return age &gt; 18;
  }
  
  public IQueryable&lt;Users&gt; GetAllMatchedUsers(Func&lt;Int32, Boolean&gt; isMatched)
  {
      return qry = _Context.Users.AsExpandable().Where(x =&gt; x.IsActive &amp;&amp; isMatched(x.Age));
  }
  </code></pre>
  
  <p>This code is used for <strong>Entity Framework ORM</strong> objects (_Context is <strong>DbContext</strong>, Users - is <strong>DBSet</strong>)</p>
  
  <p>This code throws following exception</p>
  
  <blockquote>
    <p>Unable to cast object of type
    'System.Linq.Expressions.FieldExpression' to type
    'System.Linq.Expressions.LambdaExpression'</p>
  </blockquote>
  
  <p>Getting rid of <strong>Func</strong> and hardcoding <strong>IsMatched</strong> into <strong>GetAllMatchedUsers</strong> solves this problem. But I need to use <strong>Func</strong> to pass different selection criteria from <strong>Business Logic Layer</strong> to my <strong>Data Access Layer</strong></p>
  
  <p>P. S. <strong>IsMatched</strong> is highly simplified realisation for example of course</p>
  
  <p>Help me please.</p>