protected virtual void Dispose(bool isDisposing) { if (!_disposed) { if (isDisposing) { //在这里释放托管资源 if (this._dataContext != null) { this._dataContext.Dispose(); this._dataContext = null; } _disposed = true; } //在这里释放非托管资源 } //disposed = true; }
public Repository(IDbContextProvider dbContextProvider) { _ServiceDbContext = dbContextProvider.GetDbContext(); _dbset = _ServiceDbContext.Set <E>(); }
public ServiceDbContext GetDbContext() { return(_dataContext ?? (_dataContext = new ServiceDbContext(new DbContextOptionsBuilder().UseMySql(_configuration.ConnectionString).Options))); }