Base solution for your next web application
Open Closed

unitOfManager.Current alwasy null in EventHandler #2626


User avatar
0
kamanchan created

I have develpered 2 modules, say ModuleA, and ModuleB. In ModuleB, I have created an event handler for AbpTenantBase Created, and in somewhere of ModuleA, I add a new AbpTenant record. This event handler above in moduleB is executed but _unitOfWorkManager.Current is null which is not expected by me. How can I fix this? Thanks!

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This is expected behaviour <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/EventBus-Domain-Events#entity-changes">http://aspnetboilerplate.com/Pages/Docu ... ty-changes</a>. Can you explain what you are trying to do ? Maybe we can help you in that way.

    Thanks.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    kamanchan created

    Hi,

    For example, moduleB has data associated with user records, and in moduleA there is an operation to delete user, when the user is deleted, I want to delete the associated data in moduleB. So I create a event handler for user deleted in moduleB to do the operation. However, when the event is trigger, the UnitOfManager.Current is null (in usual case, it is not null).

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can add UnitOfWork attribute to your event handler method but in 'ed' events (ex: EntityUpdated) are triggered after saving changes and no chance to rollback the unit of work.

    Can you try it that way ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)