Open Closed

Usage of Domain Events with bulk inserts #577


User avatar
0
luke created

Hello,

I've got an app with a contact list where users can bulk insert Contact. They can select to add these contacts to one or many Group, each group having a ContactGroupMember record.

There's a domain event setup on the creation and deletion of ContactGroupMember which increments Group.Members integer property. I also need to add a record to a log of when users are added and removed from groups.

I'm not sure if I should be using domain events for this or not since it will create many requests to the database in a large queue when the users bulk insert. Should I be handling this entirely manually, or is there a way to disable the domain events when bulk importing, or grouping the events into a single event?

Thank you in advance :)

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

1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    this is not a good case for a domain event. you better create a ContactManager domain service.

     public class ContactManager : DomainService, IContactManager
        {
             BulkInsertAsync();
             InsertAsync();
        }
       
    
    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 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.