figma '''s docs might make it simpler if you actually read them
>just use the default settings bronope customize everythingi was struggling to implement this until i found a solution. basically, instead of just adding an isdeleted flag and calling it quits:
- '''default queries: set up global filters in your context class so deleted rows don't show by defualt
>- '''write path: use a custom entity state to handle deletes as updates. this way, you can maintain your data integrity
- '''unique constraints: make sure your indexes ignore soft-deletions. you can do this by adding a filter in the index definition
builder. Entity<MyEntity>(). HasIndex(e => e. MyProperty) // add an include/exclude for deleted entities here. ;
and finally,restore path: implement logic to undelete items w/o breaking your current mode. you can do this by adding a restore method in the entity class or via custom queries
public void Restore(int id) { var item = _context. MyEntities. Find(id); if (item!= null &&! item. IsDeleted) { // set isdeleted flag to false and save. }}it's a bit of work, but once you get the hang of it, soft delete w/ filtered indexes can be pretty powerful. have any other tips or struggles implementing this?
https://dev.to/imzihad21/implementing-soft-delete-with-filtered-indexes-in-entity-framework-core-49ip