Refactoring SetupConsole with DBFactory
This commit is contained in:
parent
8dd01d291d
commit
78d49a9829
20 changed files with 337 additions and 407 deletions
|
|
@ -1,8 +1,10 @@
|
|||
namespace PlanTempus.Database.Core.ConnectionFactory
|
||||
{
|
||||
public interface IDbConnectionFactory
|
||||
{
|
||||
System.Data.IDbConnection Create();
|
||||
System.Data.IDbConnection Create(string username, string password);
|
||||
}
|
||||
public record ConnectionStringParameters(string user, string pwd);
|
||||
|
||||
public interface IDbConnectionFactory
|
||||
{
|
||||
System.Data.IDbConnection Create();
|
||||
System.Data.IDbConnection Create(ConnectionStringParameters connectionStringTemplateParameters);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
using System.Data;
|
||||
namespace PlanTempus.Database.Core.ConnectionFactory
|
||||
{
|
||||
|
||||
|
||||
public class PostgresConnectionFactory : IDbConnectionFactory, IAsyncDisposable
|
||||
|
||||
public class PostgresConnectionFactory : IDbConnectionFactory, IAsyncDisposable
|
||||
{
|
||||
private readonly NpgsqlDataSource _baseDataSource;
|
||||
private readonly Action<NpgsqlDataSourceBuilder> _configureDataSource;
|
||||
|
|
@ -29,13 +29,13 @@ namespace PlanTempus.Database.Core.ConnectionFactory
|
|||
return _baseDataSource.CreateConnection();
|
||||
}
|
||||
|
||||
public IDbConnection Create(string username, string password)
|
||||
public IDbConnection Create(ConnectionStringParameters param)
|
||||
{
|
||||
var connectionStringBuilder = new NpgsqlConnectionStringBuilder(
|
||||
_baseDataSource.ConnectionString)
|
||||
{
|
||||
Username = username,
|
||||
Password = password
|
||||
Username = param.user,
|
||||
Password = param.pwd
|
||||
};
|
||||
|
||||
var tempDataSourceBuilder = new NpgsqlDataSourceBuilder(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue