2025-01-02 17:53:38 -05:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Npgsql;
|
2025-01-08 17:16:27 -05:00
|
|
|
|
using CH.Dal.DbEntity;
|
|
|
|
|
using CH.Enum;
|
2025-01-02 17:53:38 -05:00
|
|
|
|
|
|
|
|
|
namespace CH.Dal;
|
|
|
|
|
|
|
|
|
|
public class CHDbContext(DbContextOptions options) : CHDbScaffoldedContext(options)
|
|
|
|
|
{
|
2025-01-08 17:16:27 -05:00
|
|
|
|
static CHDbContext() => NpgsqlConnection.GlobalTypeMapper
|
|
|
|
|
.MapEnum<Currency>("currency")
|
|
|
|
|
.MapEnum<EnergyRateExceptionTresholdResetType>("energy_rate_exception_treshold_reset_type");
|
2025-01-02 17:53:38 -05:00
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
2025-01-03 15:38:14 -05:00
|
|
|
|
base.OnModelCreating(modelBuilder);
|
2025-01-08 17:16:27 -05:00
|
|
|
|
modelBuilder.HasPostgresEnum<Currency>("currency");
|
|
|
|
|
modelBuilder.HasPostgresEnum<EnergyRateExceptionTresholdResetType>("energy_rate_exception_treshold_reset_type");
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<EnergyRate>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(e => e.Currency)
|
|
|
|
|
.HasColumnName("currency")
|
|
|
|
|
.HasColumnType("currency");
|
|
|
|
|
});
|
|
|
|
|
modelBuilder.Entity<EnergyRateException>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(e => e.ResetType)
|
|
|
|
|
.HasColumnName("reset_type")
|
|
|
|
|
.HasColumnType("energy_rate_exception_treshold_reset_type");
|
|
|
|
|
});
|
2025-01-02 17:53:38 -05:00
|
|
|
|
}
|
2025-01-03 15:38:14 -05:00
|
|
|
|
|
2025-01-02 17:53:38 -05:00
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|