当我DbContext has been disposed error
尝试使用下面提到的代码从数据库中获取数据时,我得到了。
如何解决这个问题?
public class ExampleService<T> where T : Example
{
protected readonly IRepository<T> _exampleRepository;
public ExampleService()
{
_exampleRepository= EngineContext.Current.Resolve<IRepository<T>>();
}
public IList<T> GetService()
{
var query = _exampleRepository.Table;
return query.ToList();
}
}