Allow "USER" instead of "USER ID" in the configuration

This commit is contained in:
Zoe Roux
2022-05-12 20:49:26 +02:00
parent f226b4c8b2
commit 6db43bb19a
2 changed files with 13 additions and 2 deletions
+12 -1
View File
@@ -34,10 +34,21 @@ namespace Kyoo.Database
/// <returns>A parsed connection string</returns>
public static string GetDatabaseConnection(this IConfiguration config, string database)
{
static string ToDbProperty(string key)
{
return key switch
{
"USER" => "USER ID",
_ => key
};
}
DbConnectionStringBuilder builder = new();
IConfigurationSection section = config.GetSection("database:configurations").GetSection(database);
foreach (IConfigurationSection child in section.GetChildren())
builder[child.Key] = child.Value;
{
builder[ToDbProperty(child.Key)] = child.Value;
}
return builder.ConnectionString;
}