title: LINQ to Entities: queryable extension method not reconized inside where condition
body: <p>i am using asp.net 4.5 mvc 5 with code first entity framework and have the following issue:</p>
  
  <p>i have two models, "PostBody" and "PostHeader". 1 PostHeader has 1-n PostBodies.
  A PostBody can be "Deleted" (Property as flag).</p>
  
  <p>My extension method should give me every PostBody from an IQueryable-Object which is not deleted as an IQueryable:</p>
  
  <pre><code>    public static IQueryable&lt;TSource&gt; GetActiveVersions&lt;TSource&gt;(this IQueryable&lt;TSource&gt; source)
         where TSource : PostBody
      {
          return source.Where(x =&gt; x.Deleted == false);
      }
  </code></pre>
  
  <p>this is working fine when i do somethin like this</p>
  
  <pre><code>var x = db.Bodies.GetActiveVersions().ToList();
  </code></pre>
  
  <p>or this</p>
  
  <pre><code>var y = db.Headers.FirstOrDefault().Bodies.AsQueryable().GetActiveVersions().ToList();
  </code></pre>
  
  <p>etc. - But as soon as i use my extension method as part of an expression paramater within e.g. the where method, i'm running into a NotSupportedException:</p>
  
  <pre><code>var z = db.Headers.Where(h =&gt; h.Bodies.AsQueryable().GetActiveVersions().Count() &gt; 0).ToList();
  
  System.NotSupportedException: LINQ to Entities does not recognize the method 'System.Linq.IQueryable`1[WebApplication5.Models.PostBody] GetActiveVersions[PostBody](System.Linq.IQueryable`1[WebApplication5.Models.PostBody])' method, and this method cannot be translated into a store expression.
  </code></pre>
  
  <p>what am i doing wrong? or - how can i use my extension method within the where condition?</p>