add db model and edit db context

This commit is contained in:
eugeniy_ivanov 2023-03-28 01:05:15 +05:00
parent dc8aa67344
commit 4014dd03f6
6 changed files with 88 additions and 2 deletions

View File

@ -1,4 +1,5 @@
using AsbCloudDb.Model.Subsystems;
using AsbCloudDb.Model.GTR;
using AsbCloudDb.Model.Subsystems;
using Microsoft.EntityFrameworkCore;
using System.Threading;
using System.Threading.Tasks;
@ -55,6 +56,11 @@ namespace AsbCloudDb.Model
public virtual DbSet<TelemetryWirelineRunOut> TelemetryWirelineRunOut => Set<TelemetryWirelineRunOut>();
// GTR WITS
public DbSet<WitsFloat> WitsFloat => Set<WitsFloat>();
public DbSet<WitsInt> WitsInt => Set<WitsInt>();
public DbSet<WitsStr> WitsStr => Set<WitsStr>();
// WITS
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
public DbSet<WITS.Record7> Record7 => Set<WITS.Record7>();
@ -334,6 +340,14 @@ namespace AsbCloudDb.Model
.HasJsonConversion();
});
modelBuilder.Entity<WitsBase>(entity =>
{
entity.HasKey(
nameof(ITelemetryData.IdTelemetry),
nameof(WitsBase.IdRecord),
nameof(WitsBase.IdItem));
});
modelBuilder.Entity<UserSetting>(entity =>
{

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.GTR
{
[Table("t_wits_base"), Comment("таблица данных ГТИ")]
public abstract class WitsBase : ITelemetryData
{
[Column("id_telemetry")]
public int IdTelemetry { get; set; }
[Column("id_record")]
public int IdRecord { get; set; }
[Column("id_item")]
public int IdItem { get; set; }
[Column("date", TypeName = "timestamp with time zone")]
public DateTimeOffset DateTime { get; set; }
[ForeignKey(nameof(IdTelemetry))]
public virtual Telemetry? Telemetry { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.GTR
{
[Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения float")]
public class WitsFloat : WitsBase
{
[Column("value")]
public float? Value { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.GTR
{
[Table("t_wits_int"), Comment("таблица данных ГТИ с типом значения int16 int32")]
public class WitsInt : WitsBase
{
[Column("Value", TypeName = "bigint")]
public int? Value { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace AsbCloudDb.Model.GTR
{
[Table("t_wits_string"), Comment("таблица данных ГТИ с типом значения string")]
public class WitsStr: WitsBase
{
[Column("value")]
[StringLength(64)]
public string? Value { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using AsbCloudDb.Model.Subsystems;
using AsbCloudDb.Model.GTR;
using AsbCloudDb.Model.Subsystems;
using AsbCloudDb.Model.WITS;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
@ -47,6 +48,9 @@ namespace AsbCloudDb.Model
DbSet<WellOperationCategory> WellOperationCategories { get; }
DbSet<WellSectionType> WellSectionTypes { get; }
DbSet<WellType> WellTypes { get; }
DbSet<WitsFloat> WitsFloat { get; }
DbSet<WitsInt> WitsInt { get; }
DbSet<WitsStr> WitsStr { get; }
DbSet<Driller> Drillers { get; }
DbSet<Schedule> Schedule { get; }
DbSet<OperationValue> OperationValues { get; }