Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
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!


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.

  • 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).

  • 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 ?