title: EFCore The Linq Expression Could not be translated and will be evaluated locally
body: <p>I am attempting to create a compiled query that can be executed on the database side. The idea is to create a reusable function across my code. But EF Core is still saying this query cannot be translated to sql.</p>
  
  <blockquote>
    <p>Here is the reusable <code>expression</code></p>
  </blockquote>
  
  <pre><code>public static class DisplayFilters
  {
      public static Expression&lt;Func&lt;DisplayItem, bool&gt;&gt; isActiveItem = (x) =&gt; x.IsDeleted == false;
  }
  </code></pre>
  
  <blockquote>
    <p>Here is the EFCore entity call</p>
  </blockquote>
  
  <pre><code>using df = namespace.DisplayFilters;
  ...
      [HttpGet]
      public IActionResult Get()
      {
          IEnumerable&lt;DisplayItem&gt; xItem = (from a in _context.DisplayItem.AsQueryable()
                                            where df.isActiveItem.Compile()(a)
                                            select a);
          return Ok(xItem);
      }
  </code></pre>