I am trying to create a set of tables where we do not actually delete them, but instead set the flags of the archive. When we delete an object, it should not be deleted, it should be marked as archived.
What are the programming patterns to support this?
I would also prefer not to run my own stored procs for each table that has these archive flags, if there is another solution.
This is an old question, and it does not indicate the version of EntityFramework. There are some good solutions for newer versions:
Entity Framework: Soft Deletes Easy
Entity Framework
Framework 5
EF 6.1.1 +
Rowan Millers EF6/EF7 Talk TechEd 2014
Entity Framework: Entity Framework 6
myEntity.IsArchived = true; context.SaveChanges();
, ; -)
"MarkForDeletion" .
, - , , "", .
, , , , .
, , , , . , .
.NET 4.0, EF POCOs, , , .
, DeleteObject - (EFHelper - , ), ObjectContext.DeleteObject EFHelper.DeleteObject - , . , , API- .NET reflection archive_flag EntityObject, "", .
DeleteObject
EFHelper
ObjectContext.DeleteObject
EFHelper.DeleteObject