2024-11-26 15:07:18 +05:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Persistence.Database.Entity;
|
|
|
|
using Persistence.Database.Model;
|
|
|
|
|
|
|
|
namespace Persistence.Database;
|
|
|
|
|
|
|
|
/// <summary>
|
2024-12-10 09:10:20 +05:00
|
|
|
/// EF контекст для любых БД поддерживаемых в EF
|
2024-11-26 15:07:18 +05:00
|
|
|
/// </summary>
|
|
|
|
public class PersistenceDbContext : DbContext
|
|
|
|
{
|
|
|
|
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
|
|
|
|
|
|
|
|
public DbSet<Setpoint> Setpoint => Set<Setpoint>();
|
|
|
|
|
|
|
|
public DbSet<TimestampedSet> TimestampedSets => Set<TimestampedSet>();
|
|
|
|
|
2024-12-10 11:27:22 +05:00
|
|
|
public DbSet<ChangeLog> ChangeLog => Set<ChangeLog>();
|
|
|
|
|
2024-12-12 16:56:25 +05:00
|
|
|
public DbSet<TechMessage> TechMessage => Set<TechMessage>();
|
2024-12-11 09:30:35 +05:00
|
|
|
|
2024-12-12 16:56:25 +05:00
|
|
|
public DbSet<ParameterData> ParameterData => Set<ParameterData>();
|
2024-12-11 09:30:35 +05:00
|
|
|
|
2024-12-12 17:05:47 +05:00
|
|
|
public DbSet<DataSourceSystem> DataSourceSystem => Set<DataSourceSystem>();
|
|
|
|
|
2024-12-11 09:30:35 +05:00
|
|
|
public PersistenceDbContext(DbContextOptions options)
|
2024-11-26 15:07:18 +05:00
|
|
|
: base(options)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
{
|
|
|
|
modelBuilder.Entity<TimestampedSet>()
|
|
|
|
.Property(e => e.Set)
|
|
|
|
.HasJsonConversion();
|
2024-12-10 11:27:22 +05:00
|
|
|
|
|
|
|
modelBuilder.Entity<ChangeLog>()
|
|
|
|
.Property(e => e.Value)
|
|
|
|
.HasJsonConversion();
|
2024-11-26 15:07:18 +05:00
|
|
|
}
|
|
|
|
}
|