PlanTempusApp/Core/ModuleRegistry/DbPostgreSqlModule.cs

23 lines
595 B
C#
Raw Normal View History

2025-01-03 16:21:03 +00:00
using Autofac;
using Npgsql;
using System.Data;
namespace Core.ModuleRegistry
{
2025-01-16 14:27:05 +01:00
public class DbPostgreSqlModule : Module
{
public required string ConnectionString { get; set; }
protected override void Load(ContainerBuilder builder)
{
2025-02-06 16:58:13 +01:00
Insight.Database.Providers.PostgreSQL.PostgreSQLInsightDbProvider.RegisterProvider();
2025-01-03 16:21:03 +00:00
2025-02-06 16:58:13 +01:00
builder.Register(c =>
2025-01-16 14:27:05 +01:00
{
IDbConnection connection = new NpgsqlConnection(ConnectionString);
return connection;
})
.InstancePerLifetimeScope();
2025-01-03 16:21:03 +00:00
2025-01-16 14:27:05 +01:00
}
}
2025-01-03 16:21:03 +00:00
}