protected DbProvider(Func <DbConnection> factory, string providerId, SqlFuConfig config = null) { _factory = factory; SqlFuConfiguration = config ?? SqlFuManager.Config; ProviderId = providerId; EscapeChars = GetEscapeIdentifierChars(); }
protected DbProvider(Func<DbConnection> factory,string providerId,SqlFuConfig config=null) { _factory = factory; SqlFuConfiguration = config ?? SqlFuManager.Config; ProviderId = providerId; EscapeChars = GetEscapeIdentifierChars(); }
public SqlFuConnection(IDbProvider provider, DbConnection cnx, SqlFuConfig config) { Config = config; cnx.MustNotBeNull(); provider.MustNotBeNull(); _conex = cnx; _provider = provider; _errStrategyFactory = config.TransientErrorsStrategyFactory; }
public static void RegisterSqlFuConfig(SqlFuConfig config, string schema = null) { config.ConfigureTableForPoco <Commit>(d => { d.TableName = new TableName(ASqlDbProvider.CommitsTable, schema); }); config.ConfigureTableForPoco <Snapshot>(d => { d.TableName = new TableName(ASqlDbProvider.SnapshotsTable, schema); }); config.ConfigureTableForPoco <BatchProgress>(d => d.TableName = new TableName(ASqlDbProvider.BatchTable, schema)); }
public static IDbFactory DbFactory(DbProvider provider, string cnx, Action <SqlFuConfig> config = null) { LogManager.OutputTo(w => Trace.WriteLine(w)); var c = new SqlFuConfig(); SqlFuManager.UseLogManager(); c.ConfigureTableForPoco <IdempotencyTools.IdemStore>(g => { g.TableName = new TableName(IdempotencyTools.DefaultTableName); }); config?.Invoke(c); return(c.CreateFactoryForTesting(provider, cnx)); }
public static DbConnection SqlFuConnection(DbProvider provider, string cnx, Action <SqlFuConfig> config = null) { LogManager.OutputTo(w => Debug.WriteLine(w)); var c = new SqlFuConfig(); c.UseLogManager(); c.WhenType <ArticleType>().WriteAs(a => a.ToString()); c.ConfigureTableForPoco <User>(d => { d.TableName = "Users" + new string(Guid.NewGuid().ToByteArray().ToBase64().Where(w => (w >= 'a' && w <= 'z')).Take(5).ToArray()); d.Property(f => f.Id).IsAutoincremented(); d.IgnoreProperties(f => f.Ignored); }); config?.Invoke(c); return(new SqlFuConnection(provider, cnx, c)); }
public GenericProvider(Func <DbConnection> factory, EscapeIdentifierChars escapeChars, SqlFuConfig config = null) : base(factory, Id, config) { _escapeChars = escapeChars; }
static void ConfigSql(SqlFuConfig cfg, TableName name) => cfg.ConfigureTableForPoco <IdemStore>(t => t.TableName = name);
public SqlFuConnection(IDbProvider provider, string cnxString, SqlFuConfig config) { Config = config; _errStrategyFactory = Config.TransientErrorsStrategyFactory; Init(cnxString, provider); }
public static async Task HandleTransientsAsync(DbCommand cmd, Func <CancellationToken, Task> sqlAction, IRetryOnTransientErrorsStrategy strat, IDbProvider provider, CancellationToken cancel, SqlFuConfig config) { start: try { config.OnCommand(cmd); await sqlAction(cancel).ConfigureFalse(); } catch (DbException ex) { if (provider.IsTransientError(ex)) { "SqlFu".LogInfo("Transient error detected"); if (strat.CanRetry) { var period = strat.GetWaitingPeriod(); "SqlFu".LogInfo($"Waiting {period} before retrying"); await Task.Delay(period, cancel).ConfigureFalse(); "SqlFu".LogInfo("Retrying..."); goto start; } "SqlFu".LogWarn($"No more retries left. Tried {strat.RetriesCount} times. Throwing exception"); } config.OnException(cmd, ex); throw; } }
public static void HandleTransients(DbCommand cmd, Action sqlAction, IRetryOnTransientErrorsStrategy strat, IDbProvider provider, SqlFuConfig cfg) { start: try { cfg.OnCommand(cmd); sqlAction(); } catch (DbException ex) { if (provider.IsTransientError(ex)) { "SqlFu".LogInfo("Transient error detected"); if (strat.CanRetry) { var period = strat.GetWaitingPeriod(); "SqlFu".LogInfo($"Waiting {period} before retrying"); Thread.Sleep(period); "SqlFu".LogInfo("Retrying..."); goto start; } "SqlFu".LogWarn($"No more retries left. Tried {strat.RetriesCount} times. Throwing exception"); } cfg.OnException(cmd, ex); throw; } }
public SqlFuCommand(SqlFuConnection cnx) { _cnx = cnx; _cfg = cnx.SqlFuConfig(); _cmd = cnx.Connection.CreateCommand(); }
public MultipleDbsConfigTest(ITestOutputHelper h) { _h = h; _cfg = new SqlFuConfig(); }