C#C
C#3y ago
Dusty

✅ Soft Deletions with EF Core

Hey,
instead of deleting the entry from the DB directly I am setting a IsDeleted property to true.
Generic saving etc. works already.

Now to my problem:
I don't want to call .Where(x => !x.IsDeleted) every time I query an entity as it's very error prone.

Is there any good design pattern you'd recommend to add this to (almost) every call?

What I've tried so far are global query filters.
The issue with that is that several entities depend on the entity that has this global query filter. If I remove the global query filter it works fine but then I do remove my tenant logic.
So global query filters are not an option.
Was this page helpful?