private IDbConnection OpenConnection() { CheckDispose(); IDbConnection connection = null; string key = null; if (shared && HttpContext.Current != null) { key = string.Format("Connection {0}|{1}", GetDialect(), DbRegistry.GetConnectionString(DatabaseId)); connection = DisposableHttpContext.Current[key] as IDbConnection; if (connection != null) { var state = ConnectionState.Closed; var disposed = false; try { state = connection.State; } catch (ObjectDisposedException) { disposed = true; } if (!disposed && (state == ConnectionState.Closed || state == ConnectionState.Broken)) { if (string.IsNullOrEmpty(connection.ConnectionString)) { connection.ConnectionString = DbRegistry.GetConnectionString(DatabaseId).ConnectionString; } connection.Open(); return(connection); } } } connection = DbRegistry.CreateDbConnection(DatabaseId); if (proxyContext != null) { connection = new DbConnectionProxy(connection, proxyContext); } connection.Open(); if (shared && HttpContext.Current != null) { DisposableHttpContext.Current[key] = connection; } return(connection); }
private ISqlDialect GetDialect() { return dialect ?? (dialect = DbRegistry.GetSqlDialect(DatabaseId)); }
public ConfigureDbManager(DbRegistry dbRegistry, IOptionsMonitor <ILog> option, IHttpContextAccessor httpContextAccessor) : this(dbRegistry, option) { HttpContextAccessor = httpContextAccessor; }
public ConfigureDbManager(DbRegistry dbRegistry, IOptionsMonitor <ILog> option) { DbRegistry = dbRegistry; Option = option; }