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 #2807

Merged
merged 3 commits into from
Feb 14, 2020
Merged

Conversation

gterdem
Copy link
Contributor

@gterdem gterdem commented Feb 11, 2020

Resolves #139

Added HardDelete and HardDeleteAsync methods to RepositoryExtensions.
Added HardDelete Tests for EfcoreRepository and MongoDbRepository.

Comment on lines +118 to +123
if (!IsEntity(entity.GetType()))
{
throw new AbpException(entity.GetType() + " is not an Entity !");
}

return ReflectionHelper.GetValueByPath(entity, entity.GetType(), "Id");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi
entity that implement the IEntity interface do not have an Id property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello maliming,
So you mean if an entity is inherited from Entity (or IEntity) it won't pass this check which will be causing problems. Do I get it right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Entity will pass the check, but it does not have an Id property. Only entities that inherit the IEntity<IdKeyType> interface will have an Id property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok got it now..
So it should be something like;

if (!ReflectionHelper.IsAssignableToGenericType(entity.GetType(), typeof(IEntity<>)))
{
     throw new AbpException(entity.GetType() + " is not an Entity with an Id property !");
}

Seems good to go by this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the GetKeys method of entity can be used. This way we can delete the entities that implement IEntity and IEntity<T>.

Copy link
Contributor Author

@gterdem gterdem Feb 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it is viable. Do we want to hard delete only IEntity implemented entities?
If an entity has no Id property, it can be many-to-many entity without Id property (juntion table) which we wouldn't want to hard delete them all right?

I may have lack of knowledge about use cases of Entity and IEntity though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
repository.HardDelete(entity);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi

Repositories are no longer providing synchronization methods.
#2026 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah makes sense. Will remove sync methods in next commit.

@hikalkan hikalkan added this to the 2.1 milestone Feb 14, 2020
hikalkan added a commit that referenced this pull request Feb 14, 2020
@hikalkan hikalkan merged commit 2e20131 into abpframework:dev Feb 14, 2020
@hikalkan
Copy link
Member

I merged by making some improvements and refactoring: fc8d34e

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

Successfully merging this pull request may close these issues.

Soft Delete enhancements
3 participants