Base solution for your next web application
Open Closed

UnitOfWork in DbContext #3289


User avatar
0
rishabh7m created

Is it possible to get current unit of work in DbContext? Right now i'm using like this:

_unitOfWorkManager.Current.Completed += (sender, args) => {};

I want to get Id of some entites that are created.


2 Answer(s)
  • User Avatar
    0
    fengol created

    Just so I understand, you want a delegate to execute after an entity inserted via the DBContext so you can get the Id that was used?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Why don't you use domain events <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/EventBus-Domain-Events">https://aspnetboilerplate.com/Pages/Doc ... ain-Events</a> ? You can use entity created event.

    Thanks.