public RestmeDb(ILogger logger = null) { if (logger != null) { Logger = logger; } if (DefaultConnectionString.IsNullOrEmpty()) { throw new ArgumentException( $"DefaultConnectionString is not present - try instantiate {this.GetType().Name} with a valid connection string first."); } }
private async Task <IDbConnection> GetOpenConnectionAsync(bool establishTransaction = false, string connectionString = null) { if (_currentConnection == null || _currentConnection.State == ConnectionState.Closed) { connectionString ??= _dbConnectionString; _currentConnection = new SqlConnection(connectionString); await((SqlConnection)_currentConnection).OpenAsync(); } ; if (DefaultConnectionString.IsNullOrEmpty()) { DefaultConnectionString = connectionString; } if (establishTransaction) { await GetDbTransactionAsync(); } return(_currentConnection); }