Abp: Soft Delete enhancements

Created on 26 Oct 2017  路  9Comments  路  Source: abpframework/abp

  • [ ] Provide a way of undelete.
  • [ ] Provide a way of hard delete.

Even we can consider to add an enum to all entities (like Active, InActive, Deleted) or define this enum property for SoftDelete

abp-framework effort-8 feature normal

Most helpful comment

I am moving this to v1.2. However its subject to change (we may have more prioritized issues).

All 9 comments

Can you provide more details please. I have a few doubts.

  1. A new IStateFullEntity interface must be created for EntityState data implementation? EntityState must be an Enum with Active, Inactive and Deleted values?
  2. Undelete feature must be accessible from every Repository that holds an ISoftDelete or an IStateFullEntity ?
  3. HardDelete feature must be accessible from every Repository that holds an ISoftDelete or an IStateFullEntity?
  4. I find this not clear enough (or too clear). add an enum to all entities when you say all entities you mean all entities?

Is this correct?
Please, if not, provide more info.

  1. I suggest keeping ISoftDelete and IPassivable separate, rather than IStateful.
  2. Yes.
  3. Yes.
  4. See 1. Otherwise:
    c# public interface IStateful { EntityState State { get; set; } }

So, we will have the 3 of them? (ISoftDelete, IPassivable and IStateful)

this means that if I choose to use IStateful I will have an IPassivable and ISoftDelete Entity
or
will IStateful (by itself) add those behaviors? (e.g. Filters)

As I suggested, just ISoftDelete and IPassivable.

now I got it.
same here, just ISoftDelete and IPassivable.

I'll be working on this next Friday, if there is no objection I'll drop the enum approach as suggested by @acjh and just implement Undelete and HardDelete features.

thxs @acjh

Maybe on version 1.2 @hikalkan ?

I am moving this to v1.2. However its subject to change (we may have more prioritized issues).

Thinking on both design and business wide; should HardDelete functionality only be applied to already softdeleted entities? Or an entity marked with something like IHardDelete should override ISoftDelete even if it exists, and be deleted nonetheless?

On both cases, if the entity is audited; all audition will be deleted also but I think it should be logged in somewhere that the HardDelete has been performed for corresponding entities.

I have been writing code to purge old records from the database that are marked as deleted. I used the IDataFilter to disable the ISoftDelete and expected to be able to just use IRepository.DeleteAsync to hard delete or use a method like IRepository.HardDeleteAsync. This would give the developer the option to specify what data they want using a predicate which will also allow them to skip marking the records as deleted before hard deleting them.

Example..

using (_dataFilter.Disable<ISoftDelete>())
{
    // this
    await _bookRepository.DeleteAsync(x => x.IsDeleted);
    // or this - which could implicitly disable ISoftDelete too?
    await _bookRepository.HardDeleteAsync(x => x.IsDeleted);
    // or even add an extra property like hardDelete
    await _bookRepository.DeleteAsync(x => x.IsDeleted, hardDelete: true);
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

hikalkan picture hikalkan  路  3Comments

wocar picture wocar  路  3Comments

ChangYinShung picture ChangYinShung  路  3Comments

wakuflair picture wakuflair  路  3Comments

hitaspdotnet picture hitaspdotnet  路  3Comments