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 VerificationDbContext GetDbContext() { return(_dataContext ?? (_dataContext = new VerificationDbContext(new DbContextOptionsBuilder().UseMySql(_configuration.ConnectionString).Options))); }
public Repository(IDbContextProvider dbContextProvider) { _verificationDbContext = dbContextProvider.GetDbContext(); _dbset = _verificationDbContext.Set <E>(); }