We perform delete function on EntityName
by calling the DeleteAsync
on the repository EntityNameRepository
.
However EntityName
has a number of child tables. DeleteAsync
sets the IsDeleted value to true for the EntityName
however that doesn't happen for the child entities of EntityName
.
How to cascade delete all entities associated with EntityName
12 Answer(s)
-
0
hi
https://github.com/abpframework/abp/issues/9366#issuecomment-869247128
-
0
Hi maliming :)
Thanks for the reply. I was checking out the github link you shared.
I tried to add the override for deleteasync just like how we did for the WithDetailsAsync but that didn't work out.
Do you have any reference code which we can refer to that extends deleteasync to soft delete the subcollections ?
Thank you
-
0
but that didn't work out.
Can you explains why it doesn't work?
-
0
-
0
You can see the
DeleteAsync
method in base class.https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs#L186 https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs#L439
-
0
so do we have to call deleteasync mulltiple times to delete subcollections? how do we go on and soft delete multiple subcollection. i tried x =>x.Id == id inside deleteasync but it deletes only the main record.
-
0
Hi maliming,
awaiting your support.
Thank you :)
-
0
Hi maliming,
guess you're having a busy day. We all have them ;) Waiting for your reply.
Thank you.
-
0
hi
Can you share your app source code again? liming.ma@volosoft.com
-
0
hey,
i've sent you the request to the repo.
Tx :)
-
0
-
0
Thanks maliming :) . I used separate repos for each of those collections as suggested and was able to set isdeleted as true.
Thank you