Exemplo n.º 1
0
        public static async Task <ILoggedConnection <SqlConnection> > OpenConnection(this SqlServerCfg cfg, ILogger log)
        {
            var policy = Policy.Handle <SqlException>(e => e.Number == 40143).RetryBackoff("connecting to sql server", 3, log);
            var conn   = cfg.Connection();
            await policy.ExecuteAsync(() => conn.OpenAsync());

            return(conn.AsLogged(log));
        }
Exemplo n.º 2
0
 public static string ConnectionStirng(this SqlServerCfg cfg) =>
 $"Server={cfg.Host};Initial Catalog={cfg.Db};Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=10;Pooling=true;Min Pool Size={cfg.MinPoolSize}";
Exemplo n.º 3
0
 public static SqlConnection Connection(this SqlServerCfg cfg) =>
 new SqlConnection(cfg.ConnectionStirng(), new SqlCredential(cfg.Creds.Name, cfg.Creds.SecureString()));