title: Entity Framework Filter "Expression<Func<T, bool>>"
body: <p>I'm trying to create a filter method for Entity framework List and understand better the</p>
  <p><code>Expression&lt;Func&lt;...</code></p>
  <p>I have a Test Function like this.</p>
  <pre><code>public IQueryable&lt;T&gt; Filter&lt;T&gt;(IEnumerable&lt;T&gt; src, Expression&lt;Func&lt;T, bool&gt;&gt; pred)
  {
      return src.AsQueryable().Where(pred);
  }
  </code></pre>
  <p>and if I do this:</p>
  <pre><code>context.Table.Filter(e =&gt; e.ID &lt; 500);
  </code></pre>
  <p>or this:</p>
  <pre><code>context.Table.Filter(e =&gt; e.SubTable.Where(et =&gt; et.ID &lt; 500).Count() &gt; 0 &amp;&amp; e.ID &lt; 500);
  </code></pre>
  <p>it all works well.</p>
  <p>But if I do this:</p>
  <pre><code>context.Table.Filter(e =&gt; e.SubTable.Filter(et =&gt; et.ID &lt; 500).Count() &gt; 0 &amp;&amp; e.ID &lt; 500);
  </code></pre>
  <p>or this:</p>
  <pre><code>context.Table.Where(e =&gt; e.SubTable.Filter(et =&gt; et.ID &lt; 500).Count() &gt; 0 &amp;&amp; e.ID &lt; 500);
  </code></pre>
  <p>I receive one error.
  <code>LINQ to Entities does not recognise the method ...Filter...</code></p>
  <p>Why does it work in one case and not in the other? What should I change in the filter to make it work with related tables?
  I prefer to stay away from other external libraries as what I want is to learn how it works and be able to use it in any scenario in future.</p>
  <p>In the first two cases, the filter runs in the database correctly.</p>