title: How to ignore softDelete query filter for included entities using a Repository?
body: <p>I created a DataLayer for my project that uses EfCore5, I configured my DbContext to handle softDelete records:</p>
  <pre><code>//DbContext    
  modelBuilder.Entity&lt;EntityName&gt;().HasQueryFilter(p =&gt; !p.Deleted);
  </code></pre>
  <p>In my Repository:</p>
  <pre><code>   // Repository Interface
      public interface IRepository&lt;T,TKey&gt; where T : class
      {
          ICollection&lt;T&gt; FindAll(Expression&lt;Func&lt;T, bool&gt;&gt; filter = null, Func&lt;IQueryable&lt;T&gt;, IIncludableQueryable&lt;T, object&gt;&gt; include = null, bool hideDeleted = true);
      }
  
     // Repository
     public class Repository&lt;TEntity, TKey&gt; : IRepository&lt;TEntity, TKey&gt; where TEntity : class, IEntity&lt;TKey&gt;
      {
          public ICollection&lt;TEntity&gt; FindAll(Expression&lt;Func&lt;TEntity, bool&gt;&gt; filter = null, Func&lt;IQueryable&lt;TEntity&gt;, IIncludableQueryable&lt;TEntity, object&gt;&gt; include = null, bool hideDeleted = true)
          {
              using var db = new TEGVContext();
              IQueryable&lt;TEntity&gt; query = db.Set&lt;TEntity&gt;();
              if (!hideDeleted)
                  query = query.IgnoreQueryFilters();
  
              if (include != null)
                  query = hideDeleted ? include(query) : include(query).IgnoreQueryFilters();
  
              return filter == null
                  ? query.ToList()
                  : query.Where(filter).ToList();
          }
      }
  </code></pre>
  <p>In controller:</p>
  <pre><code> var model = _Repo.FindById(id, include: a =&gt; a
                          .Include(x =&gt; x.Entity2).ThenInclude(l =&gt; l.Entity2_1)
                          .Include(x =&gt; x.Entity3).ThenInclude(l =&gt; l.Entity3_1), false);
  </code></pre>
  <p>In my code IgnoreQueryFilters works with the main Entity but not with Include and ThenInclude, the called entities in includes still applies the queryFilter.</p>
  <p>How can I make my code be able to ignorequeryfilters on selected includes? And is there a better way to do this?</p>