title: Net Core IgnoreQueryFilters custom implementation
body: <p>I am trying to create my own implementation of Net Core's IgnoreQueryFilters() method.
  This because I have to perform some extra operations when Ignoring the filters.</p>
  <p>I found the original implementation of it in efcores github project:
  <a href="https://github.com/dotnet/efcore/blob/main/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs" rel="nofollow noreferrer">https://github.com/dotnet/efcore/blob/main/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs</a></p>
  <p>My take on it is as follows. Currently, the only difference is the name of the method and class:</p>
  <pre><code>public static class SoftDeleteExtensions
  {
  
      internal static readonly MethodInfo IgnoreQueryFiltersMethodInfo = typeof(SoftDeleteExtensions).GetTypeInfo().GetDeclaredMethod(nameof(IncludeDeleted))!;
  
      public static IQueryable&lt;TEntity&gt; IncludeDeleted&lt;TEntity&gt;(this IQueryable&lt;TEntity&gt; source) where TEntity : class
      {
          if (!(source.Provider is EntityQueryProvider))
          {
              return source;
          }
          return source.Provider.CreateQuery&lt;TEntity&gt;(Expression.Call(null, IgnoreQueryFiltersMethodInfo.MakeGenericMethod(typeof(TEntity)), source.Expression));
      }
  
  }
  </code></pre>
  <p>When running the following code, it runs fine:</p>
  <pre><code>using EnevoLeadsContext context = new EnevoLeadsContext();
  List&lt;Mission&gt; missions = context.Missions.IgnoreQueryFilters().OrderBy(m =&gt; m.Id).Take(500).ToList();
  </code></pre>
  <p>However, when using my own extension:</p>
  <pre><code>using EnevoLeadsContext context = new EnevoLeadsContext();
  List&lt;Mission&gt; missions = context.Missions.IncludeDeleted().OrderBy(m =&gt; m.Id).Take(500).ToList();
  </code></pre>
  <p>I get the following error:</p>
  <blockquote>
  <p>System.InvalidOperationException   HResult=0x80131509   Message=The
  LINQ expression 'DbSet()
  .Where(m =&gt; !(m.Deleted))
  .IncludeDeleted()' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation
  explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable',
  'ToList', or 'ToListAsync'. See
  <a href="https://go.microsoft.com/fwlink/?linkid=2101038" rel="nofollow noreferrer">https://go.microsoft.com/fwlink/?linkid=2101038</a> for more information.
  Source=Microsoft.EntityFrameworkCore</p>
  </blockquote>
  <p>What is it that I'm missing?</p>