51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using DD.Persistence.Database.Entity;
|
|
using DD.Persistence.Database.Model;
|
|
|
|
namespace DD.Persistence.Database;
|
|
|
|
/// <summary>
|
|
/// EF контекст для любых БД поддерживаемых в EF
|
|
/// </summary>
|
|
public class PersistenceDbContext : DbContext
|
|
{
|
|
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
|
|
|
|
public DbSet<TagValue> TagValues => Set<TagValue>();
|
|
public DbSet<TagSetValue> TagSetValues => Set<TagSetValue>();
|
|
public DbSet<TagBag> TagBag => Set<TagBag>();
|
|
|
|
public DbSet<Setpoint> Setpoint => Set<Setpoint>();
|
|
|
|
public DbSet<TimestampedSet> TimestampedSets => Set<TimestampedSet>();
|
|
|
|
public DbSet<ChangeLog> ChangeLog => Set<ChangeLog>();
|
|
|
|
public DbSet<TechMessage> TechMessage => Set<TechMessage>();
|
|
|
|
public DbSet<ParameterData> ParameterData => Set<ParameterData>();
|
|
|
|
public DbSet<DataSourceSystem> DataSourceSystem => Set<DataSourceSystem>();
|
|
|
|
public PersistenceDbContext(DbContextOptions options)
|
|
: base(options)
|
|
{
|
|
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<TimestampedSet>()
|
|
.Property(e => e.Set)
|
|
.HasJsonConversion();
|
|
|
|
modelBuilder.Entity<ChangeLog>()
|
|
.Property(e => e.Value)
|
|
.HasJsonConversion();
|
|
|
|
modelBuilder.Entity<TagBag>()
|
|
.Property(e => e.Values)
|
|
.HasJsonConversion();
|
|
}
|
|
}
|