Open Closed

Deleteasync to delete child entities #1932


User avatar
0
Neozzz created

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

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

12 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/abpframework/abp/issues/9366#issuecomment-869247128

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Neozzz created

    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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    but that didn't work out.

    Can you explains why it doesn't work?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Neozzz created

    showing this error.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Neozzz created

    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.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Neozzz created

    Hi maliming,

    awaiting your support.

    Thank you :)

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Neozzz created

    Hi maliming,

    guess you're having a busy day. We all have them ;) Waiting for your reply.

    Thank you.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share your app source code again? liming.ma@volosoft.com

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Neozzz created

    hey,

    i've sent you the request to the repo.

    Tx :)

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can try this way.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    Neozzz created

    Thanks maliming :) . I used separate repos for each of those collections as suggested and was able to set isdeleted as true.

    Thank you

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.