title: linq to entities and store expression
body: <p>I work on project that use some dynamic linq query to an entities.
  i have huge amount of case and to avoid code duplication i refactoring to a method.
  But using method which isn't in store expression will result to throw an exception.
  One of solutions is to encapsulate method result into an expression which can be interpreted by linq to entitie query.</p>
  
  <p>Consider that code :</p>
  
  <pre><code>parentExpression = x =&gt; x.child.Any(y=&gt;IsGoodChild(y,childType, childSize));
  
  private bool IsGoodChild(child c, int childType, int childSize){
       return c.type == childType &amp;&amp; c.size == childSize;
  }
  </code></pre>
  
  <p>"parentExpression " is predicate of type "Parent" of my EF.
  This code throw an exception, "IsGoodChild" method return a boolean and can't be interpreted by linq to Entities.</p>
  
  <p>So, i would like something like this :</p>
  
  <pre><code>parentExpression = x =&gt; x.child.AsQueryable().Any(IsGoodChild(childType, childSize));
  
  private System.Linq.Expression.Expression&lt;Func&lt;child, bool&gt;&gt; IsGoodChild(int childType, int childSize){
       return  ????
  }
  </code></pre>
  
  <p>So how can i do "IsGoodChild(...)" can work even if which not take x.child attribute ? 
  Thx for advance</p>
  
  <hr>
  
  <p>Re,</p>
  
  <p>I try something, when i write lambda directly in expression like this :</p>
  
  <pre><code>parentExpression = x =&gt; x.child.Any(y=&gt;y.type == childType &amp;&amp; y.size == childSize);
  </code></pre>
  
  <p>i used extract method from resharper and generate it this :</p>
  
  <pre><code>private Expression&lt;Func&lt;child,Boolean&gt;&gt; IsGoodChildFunctional(Int32 childType, Int32 childSize)
  {
      return c =&gt; c.type == childType &amp;&amp; c.size == childSize; 
  }
  </code></pre>
  
  <p>But i also have .NET Framework Data Provider error 1025' error ...</p>