Beispiel #1
0
 public static IDbConnection getConnection(String location)
 {
     if (location.SequenceEqual("aws"))
     {
         String  secretString     = AwsSecretManager.Get("PostgresSecret");
         JObject secret           = JObject.Parse(secretString);
         String  host             = secret.GetValue("host").ToObject(typeof(String)).ToString();
         String  username         = secret.GetValue("username").ToObject(typeof(String)).ToString();
         String  password         = secret.GetValue("password").ToObject(typeof(String)).ToString();
         String  dbName           = secret.GetValue("dbname").ToObject(typeof(String)).ToString();
         String  connectionString = new StringBuilder()
                                    .Append("Host=").Append(host)
                                    .Append(";Username="******";Password="******";Database=").Append(dbName).ToString();
         return(new NpgsqlConnection(connectionString));
     }
     else
     {
         MyConfigurationHelper myConfigurationManager = new MyConfigurationHelper();
         return(new SqlConnection(myConfigurationManager.getDBConnectionString()));
     }
 }
        public static IDbConnection getConnection()
        {
            MyConfigurationHelper myConfigurationManager = new MyConfigurationHelper();

            return(new NpgsqlConnection(myConfigurationManager.getDBConnectionString()));
        }