Search code examples
c#unit-of-workaspnetboilerplate

Where() after repostory GetAll(), shows DbContext has been disposed


Exceptions Screenshot:

Exceptions Screenshot

ABP Official Test Case: ABP Official Test Case

Actually, I am studying the ABP source code for building a new project using the unit of work module of ABP.

I wonder why this shows "the DbContext has been disposed", because In ABP, repository is defined as UOW.

An other situation is that, if I manually set a UOW class, the call will be ok as below.

Configuration.UnitOfWork.ConventionalUowSelectors.Add(type => type == typeof(MyCustomUowClass));

ABP framework was helped me I lot, once I began to work on the road of solution architecture.

It's important for me to figure out How this won't work.

Thanks for reading.


It's not a simple question, i know it should be disposed after using it.

but i don't know where to disposed, because it relate to the UOW of ABP methodology. I may missed something in somewhere.


Solution

  • Try moving the faulting code to inside the using block. Exiting using block means the variable has been disposed off and can't used anymore.