Base solution for your next web application
Open Closed

Disposing IRepository objects #2371


User avatar
0
akash created

Hi,

I am interested in knowing how IRepository objects (that I believe are transient objects) get disposed-off in abp boilerplate v0.8.3 ? These objects gets create via constructor injection in application service

Can someone here throw some light on this, please.

Thanks


2 Answer(s)
  • User Avatar
    0
    chrisk created

    Hi

    Are you getting exception in regards of IRepository being disposed or is it coming from somewhere lover down the stack, like DbContext disposed exception?

    I had issues before where my DbContext would be disposed but the reason for that was misusing the framework and not understanding UnitOfWork. Make sure when your code operates on DB that UnitOfWork is applied. [http://www.aspnetboilerplate.com/Pages/Documents/Unit-Of-Work])

    Hope that helps

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @Akash,

    Do you use repositories in MVC or WebAPI projects ? If so, please read ASP.NET MVC & ASP.NET Web API integration section of this document <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Dependency-Injection">http://aspnetboilerplate.com/Pages/Docu ... -Injection</a>.

    Basically, repository is disposed(if Transient) when the main class is disposed.