21 lines
515 B
C#
21 lines
515 B
C#
using Autofac;
|
|
using Npgsql;
|
|
using System.Data;
|
|
namespace Core.ModuleRegistry
|
|
{
|
|
public class DbPostgreSqlModule : Module
|
|
{
|
|
public required string ConnectionString { get; set; }
|
|
protected override void Load(ContainerBuilder builder)
|
|
{
|
|
|
|
builder.Register(c =>
|
|
{
|
|
IDbConnection connection = new NpgsqlConnection(ConnectionString);
|
|
return connection;
|
|
})
|
|
.InstancePerLifetimeScope();
|
|
|
|
}
|
|
}
|
|
}
|