Dbcontext disposed exception

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi,

Im having "The operation cannot be completed because the DbContext has been disposed" error. Here is my code

//ctor
public test(IStoreService storeService,
            IProductService productService)
        {
            this._storeService = storeService;
            this._productService = productService;
        }

//methods
public void Generate()
{
var stores = _storeService.GetAllStores();
foreach (var str in stores)
    {
        var products = _productService.SearchProducts(storeId: str.Id); //error throws at here
    }
}

Anyone knows why is _storeService is working but _productService has error?
6 years ago
You should confirm which class _productService belongs to and find SearchProducts method
6 years ago
Hi,

please try this

var _productService = EngineContext.Current.Resolve<IProductService>();

for more explanation please refer this link.
6 years ago
Thanks NopSquare
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.