What is the elegant way of the soft delete on EntityFramework? I have already identified a property (database field) as deleted and always use this filter on linq statements.
Like
Foo Class
int NumberField
string Description
bool Deleted
contexts.Foos.Where(x=> !x.Deleted);
It is not feasible on complex queries.
I just looked these solutions..
Link 1, Link 2
Any help appreciated..
Yes this possible with EF via pattern.
If you use a Fascade/repository pattern and access EVERY time via that fascade.
eg
an implementation of an interface on ALL repository classes might look like this:
You would access exactly as if it was the original DbSet.
EF will combine the conditions.