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