21 lines
582 B
C#
21 lines
582 B
C#
using System.Data;
|
|
using Npgsql;
|
|
|
|
namespace MieSystem.Data;
|
|
|
|
public class NpgsqlConnectionFactory
|
|
{
|
|
private readonly string _connectionString;
|
|
|
|
public NpgsqlConnectionFactory(IConfiguration configuration)
|
|
{
|
|
_connectionString = configuration.GetConnectionString("PostgreSQL")
|
|
?? throw new InvalidOperationException("ConnectionString PostgreSQL no configurada");
|
|
}
|
|
|
|
public Task<IDbConnection> CreateAsync()
|
|
{
|
|
IDbConnection conn = new NpgsqlConnection(_connectionString);
|
|
return Task.FromResult(conn);
|
|
}
|
|
} |