public static MySqlConnectionSettings GetSettings(DbConnection connection, MySqlRetryNoDependendiciesExecutionStrategy mySqlRetryNoDependendiciesExecutionStrategy) { var csb = new MySqlConnectionStringBuilder(connection.ConnectionString); var settingsCsb = _settingsCsb(csb); return(Settings.GetOrAdd(settingsCsb.ConnectionString, key => { var opened = false; if (connection.State == ConnectionState.Closed) { mySqlRetryNoDependendiciesExecutionStrategy.Execute(() => { connection.Open(); }); opened = true; } try { var version = new ServerVersion(connection.ServerVersion); var connectionSettings = new MySqlConnectionSettings(settingsCsb, version); return connectionSettings; } finally { if (opened) { connection.Close(); } } })); }
public virtual void Initialize(IDbContextOptions options) { _relationalOptions = options.FindExtension <MySqlOptionsExtension>() ?? new MySqlOptionsExtension(); if (_relationalOptions.ExecutionStrategyFactory != null) { _mySqlRetryNoDependendiciesExecutionStrategy = new MySqlRetryNoDependendiciesExecutionStrategy((MySqlRetryingExecutionStrategy)_relationalOptions.ExecutionStrategyFactory(null)); } else { _mySqlRetryNoDependendiciesExecutionStrategy = new MySqlRetryNoDependendiciesExecutionStrategy(); } }
public static MySqlConnectionSettings GetSettings(string connectionString, MySqlRetryNoDependendiciesExecutionStrategy mySqlRetryNoDependendiciesExecutionStrategy) { var csb = new MySqlConnectionStringBuilder(connectionString); var settingsCsb = _settingsCsb(csb); return(Settings.GetOrAdd(settingsCsb.ConnectionString, key => { csb.Database = ""; csb.Pooling = false; string serverVersion = ""; mySqlRetryNoDependendiciesExecutionStrategy.Execute(() => { using (var schemalessConnection = new MySqlConnection(csb.ConnectionString)) { schemalessConnection.Open(); serverVersion = schemalessConnection.ServerVersion; } }); var version = new ServerVersion(serverVersion); return new MySqlConnectionSettings(settingsCsb, version); })); }