Skip to content

Soft Delete enhancements #139 - #2807

Merged
hikalkan merged 3 commits into
abpframework:devfrom
gterdem:pr/139-hardDelete
Feb 14, 2020
Merged

Soft Delete enhancements #139#2807
hikalkan merged 3 commits into
abpframework:devfrom
gterdem:pr/139-hardDelete

Conversation

@gterdem

@gterdem gterdem commented Feb 11, 2020

Copy link
Copy Markdown
Contributor

Resolves #139

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

@gterdem
gterdem requested a review from hikalkan February 11, 2020 10:17
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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>.

@gterdem gterdem Feb 12, 2020

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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