LinqToDB.EntityFrameworkCore IgnoreFilters() does not disable global filters on some queries

89 Views Asked by At
  • I use global filter from Microsoft.EntityFrameworkCore 3.1.9 on my table Object (…HasQueryFilter(x => !x.IsDeleted)

  • I am also using LinqToDB.EntityFrameworkCore 3.7.0 for updating and deleting records in db.

  • To disable filter on queries generated by LinqToDB as I understood I cannot use .IgnoreQueryFilters() from Microsoft.EntityFrameworkCore (correct if I am wrong).

  • In any case, currently I use .IgnoreFilters() on such queries, however it seems for me that it does not disable filter in below case.

CASE

  • I have the following Linq

ctx.MainObjects.IgnoreFilters().Where(mo => mo.Objects.Count == 0).DeleteAsync();

This part “mo.Objects.Count == 0” is translated as below i.e. contains global filter still applied.

                SELECT
                    Count(*)
                FROM
                    database."Objects" x
                WHERE
                    **x."IsDeleted" = False** AND mo."Id" = mo."MainObjectId" 

QUESTION

  • Can somebody advise how to disable this filter on such queries?

WHAT I TRIED

  1. I tried to use .IgnoreQueryFilters() but i got some exceptions as index out of range smth like that.

  2. I googled and did not find anything on such exception.

  3. I tried to find some docs re this case but found nothing

0

There are 0 best solutions below