Global query filters are very handy when implementing tenant and soft deletion features.
But my problem is is that when i write a query with joins, for instance
dbContext
.entity1
.Include("entity2.entity3.entity4")
.Where(something)
.select(something)
.toList();
and every one of those entities has global filters, then in the generated SQL i get for every JOIN a full Subquery where it selects all fields of that entity and checks for the global filters.
But i dont want that. I want the global filters to only apply to the root entity of the query (entity1), and all the other entities to join normaly.
btw the relationships of the entities are:
- 1 entity4 -> N entity3
- 1 entity3 -> N entity2
- 1 entity2 -> N entity1
In my case, every entity gets its "tenant" field set and when soft deleting an entity, that soft deletion is cascaded to all its children and subchildren. Because of that checking those fields for every join is a complete waste of time.