Introduce bulk entity events
Is there an existing issue for this?
- [X] I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
consider this scenario: you have a separate algolia search server, and you want to sync data between your database and the algolia index.
the current solution is to implement ILocalEventHandler<EntityChangedEventData<TEntity>>.
this works when only a single entity is getting changed, but not for InsertMany,UpdateMany,DeleteMany since they will introduce the N+1 problem
Describe the solution you'd like
I suggest that new events to get introduced:
IBulkEntityChangeEventHelperpublic interface IBulkEntityChangeEventHelper { void PublishEntityCreatedEvent(IEnumerable<object> entity); void PublishEntityUpdatedEvent(IEnumerable<object> entity); void PublishEntityDeletedEvent(IEnumerable<object> entity); }BulkEntityEventData-> contains a list of entitiesBulkEntityChangedEventData-> fired when many entities are changedBulkEntityCreatedEventData-> fired when many entities are createdBulkEntityUpdatedEventData-> fired when many entities are updatedBulkEntityDeletedEventData-> fired when many entities are deleted
and then we can add a configuration for users to override the behavior of InsertMany, UpdateMany,DeleteMany to control whether the old events EntityChangedEventData are fired alongside the new bulk ones or not
Additional context
No response
I think the BulkEntitySomeEventData is difficult for event handling. When creating a handler, we must determine whether an entity used bulk operations.
I think it's safer to assume all operations are bulk operations than to assume operations are done individually
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Would be great to have something like this - especially when entities have dependencies, processing each event individually lead to problems where the dependency is not available yet (which mean that the order gets important).
If you have Entity A and B with dependencies of A->B and B->A, you cant handle it without having the whole picture aka a single bulk/many event.