Open CumpsD opened 1 year ago
How about something like:
private static readonly ConcurrentDictionary<string, NpgsqlDataSource> DataSources = new();
protected override DbConnection CreateDbConnection(string connectionString)
{
var dataSource = DataSources.GetOrAdd(connectionString,
x =>
{
var dataSourceBuilder = new NpgsqlDataSourceBuilder(x);
// Possibly provide extension method here?
return dataSourceBuilder.Build();
});
return dataSource.CreateConnection();
}
Describe the solution you'd like
https://www.npgsql.org/doc/release-notes/7.0.html#dbdatasource
Make use of the new
NpgsqlDataSource
from Npgsql, which allows things on a higher level