Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soft Delete enhancements #139

Closed
2 tasks
hikalkan opened this issue Oct 26, 2017 · 9 comments · Fixed by #2807
Closed
2 tasks

Soft Delete enhancements #139

hikalkan opened this issue Oct 26, 2017 · 9 comments · Fixed by #2807

Comments

@hikalkan
Copy link
Member

hikalkan commented Oct 26, 2017

  • 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

@hikalkan hikalkan added this to the Backlog milestone Oct 2, 2018
@epgeroy
Copy link

epgeroy commented Oct 2, 2018

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.

@acjh
Copy link
Contributor

acjh commented Oct 3, 2018

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

@epgeroy
Copy link

epgeroy commented Oct 3, 2018

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)

@acjh
Copy link
Contributor

acjh commented Oct 3, 2018

As I suggested, just ISoftDelete and IPassivable.

@epgeroy
Copy link

epgeroy commented Oct 3, 2018

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

@marcelo-maciel
Copy link
Contributor

Maybe on version 1.2 @hikalkan ?

@hikalkan
Copy link
Member Author

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

@hikalkan hikalkan modified the milestones: backlog, 1.2 Nov 11, 2019
@gterdem
Copy link
Contributor

gterdem commented Dec 27, 2019

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.

@hikalkan hikalkan modified the milestones: 2.0, 2.1 Jan 7, 2020
@olicooper
Copy link
Contributor

olicooper commented Jan 31, 2020

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants