DD.WellWorkover.Cloud/AsbCloudDb/Model/AsbCloudDbContext.cs

684 lines
30 KiB
C#
Raw Normal View History

2023-03-28 01:05:15 +05:00
using AsbCloudDb.Model.GTR;
using Microsoft.EntityFrameworkCore;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudDb.Model.DailyReports;
using AsbCloudDb.Model.Manuals;
using AsbCloudDb.Model.ProcessMaps;
using AsbCloudDb.Model.WellSections;
using AsbCloudDb.Model.Trajectory;
namespace AsbCloudDb.Model
{
public partial class AsbCloudDbContext : DbContext, IAsbCloudDbContext
{
public virtual DbSet<Cluster> Clusters => Set<Cluster>();
public virtual DbSet<Company> Companies => Set<Company>();
public virtual DbSet<CompanyType> CompaniesTypes => Set<CompanyType>();
2024-06-26 10:58:59 +05:00
public virtual DbSet<DailyReport> DailyReports => Set<DailyReport>();
public virtual DbSet<Deposit> Deposits => Set<Deposit>();
public virtual DbSet<DetectedOperation> DetectedOperations => Set<DetectedOperation>();
2023-11-30 09:40:51 +05:00
public virtual DbSet<TrajectoryPlan> TrajectoriesPlan => Set<TrajectoryPlan>();
public virtual DbSet<ProcessMapPlanRotor> ProcessMapPlanRotor => Set<ProcessMapPlanRotor>();
public virtual DbSet<ProcessMapPlanSlide> ProcessMapPlanSlide => Set<ProcessMapPlanSlide>();
2024-02-21 15:08:51 +05:00
public virtual DbSet<ProcessMapPlanReam> ProcessMapPlanReams => Set<ProcessMapPlanReam>();
public virtual DbSet<ProcessMapPlanOperationReamingRotor> ProcessMapPlanOperationReamingRotor => Set<ProcessMapPlanOperationReamingRotor>();
2024-06-24 16:05:45 +05:00
public virtual DbSet<ProcessMapPlanOperationReamingSlide> ProcessMapPlanOperationReamingSlide => Set<ProcessMapPlanOperationReamingSlide>();
2024-06-24 16:45:58 +05:00
public virtual DbSet<ProcessMapPlanOperationLoadCapacity> ProcessMapPlanOperationLoadCapacity => Set<ProcessMapPlanOperationLoadCapacity>();
public virtual DbSet<ProcessMapPlanSurvey> ProcessMapPlanSurvey => Set<ProcessMapPlanSurvey>();
public virtual DbSet<ProcessMapPlanOperationPositioningOffTheBottom> ProcessMapPlanOperationPositioningOffTheBottom => Set<ProcessMapPlanOperationPositioningOffTheBottom>();
public virtual DbSet<ProcessMapPlanOscillationAngles> ProcessMapPlanOperationDeterminationOfOscillationAngles => Set<ProcessMapPlanOscillationAngles>();
2024-06-25 15:22:32 +05:00
public virtual DbSet<ProcessMapPlanOperationTFOrientation> ProcessMapPlanOperationTFOrientation => Set<ProcessMapPlanOperationTFOrientation>();
public virtual DbSet<ProcessMapPlanOperationSwitchPump> ProcessMapPlanOperationSwitchPump => Set<ProcessMapPlanOperationSwitchPump>();
public virtual DbSet<ProcessMapPlanOperationSwitchingToTheMode> ProcessMapPlanOperationSwitchMode => Set<ProcessMapPlanOperationSwitchingToTheMode>();
2024-06-29 21:50:28 +05:00
public virtual DbSet<ProcessMapPlanDrillTest> ProcessMapPlanFunctionsDrillTest => Set<ProcessMapPlanDrillTest>();
2024-06-26 11:42:10 +05:00
public virtual DbSet<ProcessMapPlanFunctionsShockTest> ProcessMapPlanFunctionsShockTest => Set<ProcessMapPlanFunctionsShockTest>();
2024-06-26 13:01:06 +05:00
public virtual DbSet<ProcessMapPlanFunctionsDamper> ProcessMapPlanFunctionsDamper => Set<ProcessMapPlanFunctionsDamper>();
2024-06-29 21:32:53 +05:00
public virtual DbSet<ProcessMapPlanAutoHoldTF> ProcessMapPlanFunctionsAutoHold => Set<ProcessMapPlanAutoHoldTF>();
public virtual DbSet<ProcessMapPlanFunctionsJarrDrillTool> ProcessMapPlanFunctionsJarrDrillTool => Set<ProcessMapPlanFunctionsJarrDrillTool>();
public virtual DbSet<ProcessMapPlanUpdatingNoloadParameters> ProcessMapPlanFunctionsUpgradeNoload => Set<ProcessMapPlanUpdatingNoloadParameters>();
2024-06-29 21:26:43 +05:00
public virtual DbSet<ProcessMapPlanOscillation> ProcessMapPlanFunctionsOscillation => Set<ProcessMapPlanOscillation>();
public virtual DbSet<ProcessMapPlanAntiCrashRotation> ProcessMapPlanFunctionsAnticrashRotation => Set<ProcessMapPlanAntiCrashRotation>();
public virtual DbSet<ProcessMapPlanStaticMeasurementOutput> ProcessMapPlanFunctionsStaticMeasure => Set<ProcessMapPlanStaticMeasurementOutput>();
public virtual DbSet<DrillingProgramPart> DrillingProgramParts => Set<DrillingProgramPart>();
public virtual DbSet<FileCategory> FileCategories => Set<FileCategory>();
public virtual DbSet<FileInfo> Files => Set<FileInfo>();
public virtual DbSet<FileMark> FileMarks => Set<FileMark>();
public virtual DbSet<Measure> Measures => Set<Measure>();
public virtual DbSet<MeasureCategory> MeasureCategories => Set<MeasureCategory>();
public virtual DbSet<Permission> Permissions => Set<Permission>();
public virtual DbSet<RelationCompanyWell> RelationCompaniesWells => Set<RelationCompanyWell>();
public virtual DbSet<RelationUserDrillingProgramPart> RelationDrillingProgramPartUsers => Set<RelationUserDrillingProgramPart>();
public virtual DbSet<RelationUserRolePermission> RelationUserRolePermissions => Set<RelationUserRolePermission>();
public virtual DbSet<RelationUserRoleUserRole> RelationUserRoleUserRoles => Set<RelationUserRoleUserRole>();
public virtual DbSet<RelationUserUserRole> RelationUserUserRoles => Set<RelationUserUserRole>();
public virtual DbSet<RelationContactWell> RelationContactsWells => Set<RelationContactWell>();
public virtual DbSet<ReportProperty> ReportProperties => Set<ReportProperty>();
public virtual DbSet<SetpointsRequest> SetpointsRequests => Set<SetpointsRequest>();
public virtual DbSet<Subsystem> Subsystems => Set<Subsystem>();
public virtual DbSet<Telemetry> Telemetries => Set<Telemetry>();
public virtual DbSet<TelemetryDataSaub> TelemetryDataSaub => Set<TelemetryDataSaub>();
public virtual DbSet<TelemetryDataSaubStat> TelemetryDataSaubStats => Set<TelemetryDataSaubStat>();
public virtual DbSet<TelemetryDataSpin> TelemetryDataSpin => Set<TelemetryDataSpin>();
public virtual DbSet<TelemetryEvent> TelemetryEvents => Set<TelemetryEvent>();
public virtual DbSet<TelemetryMessage> TelemetryMessages => Set<TelemetryMessage>();
public virtual DbSet<TelemetryUser> TelemetryUsers => Set<TelemetryUser>();
public virtual DbSet<User> Users => Set<User>();
public virtual DbSet<UserRole> UserRoles => Set<UserRole>();
2022-07-27 18:14:07 +05:00
public virtual DbSet<UserSetting> UserSettings => Set<UserSetting>();
public virtual DbSet<Well> Wells => Set<Well>();
public virtual DbSet<WellComposite> WellComposites => Set<WellComposite>();
public virtual DbSet<WellOperation> WellOperations => Set<WellOperation>();
public virtual DbSet<WellOperationCategory> WellOperationCategories => Set<WellOperationCategory>();
public virtual DbSet<WellSectionType> WellSectionTypes => Set<WellSectionType>();
public virtual DbSet<WellType> WellTypes => Set<WellType>();
public virtual DbSet<Driller> Drillers => Set<Driller>();
public virtual DbSet<Schedule> Schedule => Set<Schedule>();
public virtual DbSet<OperationValue> OperationValues => Set<OperationValue>();
public virtual DbSet<WellFinalDocument> WellFinalDocuments => Set<WellFinalDocument>();
public virtual DbSet<LimitingParameter> LimitingParameter => Set<LimitingParameter>();
public virtual DbSet<TelemetryWirelineRunOut> TelemetryWirelineRunOut => Set<TelemetryWirelineRunOut>();
2023-11-30 09:40:51 +05:00
public virtual DbSet<TrajectoryFact> TrajectoriesFact => Set<TrajectoryFact>();
2024-06-26 10:58:59 +05:00
2023-12-13 18:06:48 +05:00
public virtual DbSet<WellSectionPlan> WellSectionsPlan => Set<WellSectionPlan>();
2023-03-28 01:05:15 +05:00
// GTR WITS
public DbSet<WitsItemFloat> WitsItemFloat => Set<WitsItemFloat>();
public DbSet<WitsItemInt> WitsItemInt => Set<WitsItemInt>();
public DbSet<WitsItemString> WitsItemString => Set<WitsItemString>();
2023-03-28 01:05:15 +05:00
2022-04-01 17:55:44 +05:00
// WITS
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
public DbSet<WITS.Record7> Record7 => Set<WITS.Record7>();
public DbSet<WITS.Record8> Record8 => Set<WITS.Record8>();
public DbSet<WITS.Record50> Record50 => Set<WITS.Record50>();
public DbSet<WITS.Record60> Record60 => Set<WITS.Record60>();
public DbSet<WITS.Record61> Record61 => Set<WITS.Record61>();
private static int referenceCount;
public static int ReferenceCount => referenceCount;
public DbSet<Faq> Faqs => Set<Faq>();
public DbSet<HelpPage> HelpPages => Set<HelpPage>();
public DbSet<Notification> Notifications => Set<Notification>();
public DbSet<NotificationCategory> NotificationCategories => Set<NotificationCategory>();
public DbSet<Manual> Manuals => Set<Manual>();
public DbSet<ManualDirectory> ManualDirectories => Set<ManualDirectory>();
2023-10-09 12:20:00 +05:00
public DbSet<Contact> Contacts => Set<Contact>();
public DbSet<DrillTest> DrillTests => Set<DrillTest>();
public DbSet<DataSaubStat> DataSaubStat => Set<DataSaubStat>();
2021-09-07 14:04:30 +05:00
public AsbCloudDbContext() : base()
2022-04-11 18:00:34 +05:00
{
Interlocked.Increment(ref referenceCount);
2021-09-10 11:28:57 +05:00
}
2021-09-07 14:04:30 +05:00
public AsbCloudDbContext(DbContextOptions<AsbCloudDbContext> options)
: base(options)
{
Interlocked.Increment(ref referenceCount);
}
~AsbCloudDbContext()
{
Interlocked.Decrement(ref referenceCount);
2021-09-10 11:28:57 +05:00
}
2021-09-07 14:04:30 +05:00
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2024-06-26 10:58:59 +05:00
{
2021-09-07 14:04:30 +05:00
if (!optionsBuilder.IsConfigured)
optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True;"
//, builder=>builder.EnableRetryOnFailure(2, System.TimeSpan.FromMinutes(1))
);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasPostgresExtension("adminpack")
.HasAnnotation("Relational:Collation", "Russian_Russia.1251");
modelBuilder.Entity<Deposit>(entity =>
{
entity.Property(e => e.Timezone)
.HasJsonConversion();
});
modelBuilder.Entity<Cluster>(entity =>
{
entity.HasOne(d => d.Deposit)
.WithMany(p => p.Clusters)
.HasForeignKey(d => d.IdDeposit)
.HasConstraintName("t_cluster_t_deposit_id_fk");
entity.Property(e => e.Timezone)
.HasJsonConversion();
2024-06-26 10:58:59 +05:00
});
modelBuilder.Entity<Well>(entity =>
{
entity.HasOne(d => d.Cluster)
.WithMany(p => p.Wells)
.HasForeignKey(d => d.IdCluster)
.HasConstraintName("t_well_t_cluster_id_fk");
entity.HasOne(d => d.Telemetry)
.WithOne(p => p.Well)
.HasForeignKey<Well>(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.SetNull)
.HasConstraintName("t_well_t_telemetry_id_fk");
entity.Property(e => e.Timezone)
.HasJsonConversion();
});
modelBuilder.Entity<Telemetry>(entity =>
{
entity.Property(e => e.Info)
.HasJsonConversion();
entity.Property(e => e.TimeZone)
.HasJsonConversion();
});
2021-10-12 10:39:42 +05:00
modelBuilder.Entity<WellComposite>(entity =>
{
entity.HasKey(
nameof(WellComposite.IdWell),
nameof(WellComposite.IdWellSrc),
nameof(WellComposite.IdWellSectionType));
entity.HasOne(d => d.Well)
.WithMany(p => p.WellComposites)
.HasForeignKey(d => d.IdWell)
.HasConstraintName("t_well_сomposite_t_well_id_fk");
entity.HasOne(d => d.WellSrc)
.WithMany(p => p.WellCompositeSrcs)
.HasForeignKey(d => d.IdWellSrc)
.HasConstraintName("t_well_сomposite_src_t_well_id_fk");
entity.HasOne(d => d.WellSectionType)
.WithMany(p => p.WellComposites)
.HasForeignKey(d => d.IdWellSectionType)
2021-10-12 10:39:42 +05:00
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk");
});
modelBuilder.Entity<TelemetryDataSaub>(entity =>
{
entity.HasOne(d => d.Telemetry)
.WithMany(p => p.DataSaub)
.HasForeignKey(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_telemetry_data_saub_t_telemetry_id_fk");
2022-04-01 17:55:44 +05:00
entity.HasKey(nameof(ITelemetryData.IdTelemetry), nameof(ITelemetryData.DateTime));
});
modelBuilder.Entity<WITS.RecordBase>(entity =>
{
entity.HasKey(nameof(ITelemetryData.IdTelemetry), nameof(ITelemetryData.DateTime));
});
modelBuilder.Entity<TelemetryDataSpin>(entity =>
{
entity.HasOne(d => d.Telemetry)
.WithMany(p => p.DataSpin)
.HasForeignKey(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_telemetry_data_spin_t_telemetry_id_fk");
2022-04-01 17:55:44 +05:00
entity.HasKey(nameof(ITelemetryData.IdTelemetry), nameof(ITelemetryData.DateTime));
});
2021-08-10 15:53:11 +05:00
modelBuilder.Entity<TelemetryMessage>(entity =>
{
entity.HasOne(d => d.Telemetry)
.WithMany(p => p.Messages)
.HasForeignKey(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_messages_t_telemetry_id_fk");
});
modelBuilder.Entity<TelemetryUser>(entity =>
{
2021-04-23 10:21:25 +05:00
entity.HasKey(nameof(TelemetryUser.IdTelemetry), nameof(TelemetryUser.IdUser));
entity.HasOne(d => d.Telemetry)
2021-04-23 10:21:25 +05:00
.WithMany(p => p.Users)
.HasForeignKey(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_telemetry_user_t_telemetry_id_fk");
});
2021-08-10 15:53:11 +05:00
modelBuilder.Entity<TelemetryEvent>(entity =>
2021-04-23 10:21:25 +05:00
{
2021-08-10 15:53:11 +05:00
entity.HasKey(nameof(TelemetryEvent.IdTelemetry), nameof(TelemetryEvent.IdEvent));
2021-04-23 10:21:25 +05:00
entity.HasOne(d => d.Telemetry)
.WithMany(p => p.Events)
.HasForeignKey(d => d.IdTelemetry)
.OnDelete(DeleteBehavior.Cascade)
2021-04-23 10:21:25 +05:00
.HasConstraintName("t_event_t_telemetry_id_fk");
});
modelBuilder.Entity<User>(entity =>
{
entity.HasOne(d => d.Company)
.WithMany(p => p.Users)
.HasForeignKey(d => d.IdCompany)
.OnDelete(DeleteBehavior.SetNull)
2021-07-21 15:22:58 +05:00
.HasConstraintName("t_user_t_company_id_fk");
entity.HasIndex(d => d.Login)
.IsUnique();
});
modelBuilder.Entity<RelationCompanyWell>(entity =>
{
2021-07-21 16:30:57 +05:00
entity.HasKey(nameof(RelationCompanyWell.IdCompany), nameof(RelationCompanyWell.IdWell));
entity.HasOne(r => r.Well)
.WithMany(w => w.RelationCompaniesWells)
.HasForeignKey(r => r.IdWell)
.HasConstraintName("t_relation_company_well_t_well_id_fk");
entity.HasOne(r => r.Company)
.WithMany(w => w.RelationCompaniesWells)
.HasForeignKey(r => r.IdCompany)
.HasConstraintName("t_relation_company_well_t_company_id_fk");
});
2022-04-11 18:00:34 +05:00
modelBuilder.Entity<RelationUserRoleUserRole>(entity =>
{
entity.HasKey(x => new { x.Id, x.IdInclude })
.HasName("t_relation_user_role_user_role_pk");
});
2022-04-11 18:00:34 +05:00
modelBuilder.Entity<RelationUserDrillingProgramPart>(entity =>
{
entity.HasKey(x => new { x.IdUser, x.IdDrillingProgramPart })
.HasName("t_relation_user_drilling_program_part_pk");
});
modelBuilder.Entity<WellOperation>(entity =>
2021-08-13 15:37:33 +05:00
{
entity.HasIndex(d => d.DepthEnd);
entity.HasIndex(d => d.DateStart);
2024-06-26 10:58:59 +05:00
entity.HasOne(o => o.OperationPlan)
.WithMany()
.HasForeignKey(o => o.IdPlan)
.OnDelete(DeleteBehavior.SetNull);
2021-08-13 15:37:33 +05:00
});
2022-04-11 18:00:34 +05:00
modelBuilder.Entity<DrillingProgramPart>(entity =>
{
entity.HasIndex(x => new { x.IdWell, x.IdFileCategory })
.IsUnique();
});
modelBuilder.Entity<Measure>(entity =>
{
entity.Property(e => e.Data)
.HasJsonConversion();
});
modelBuilder.Entity<FileMark>(entity =>
{
entity.HasOne(d => d.User)
.WithMany(p => p.FileMarks)
.HasForeignKey(d => d.IdUser)
2022-04-11 18:00:34 +05:00
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_user_t_file_mark_fk");
entity.HasOne(d => d.FileInfo)
.WithMany(p => p.FileMarks)
.HasForeignKey(d => d.IdFile)
.OnDelete(DeleteBehavior.Cascade)
.HasConstraintName("t_file_mark_t_file_info_fk");
});
2022-04-11 18:00:34 +05:00
modelBuilder.Entity<RelationUserUserRole>(entity =>
{
entity.HasKey(e => new { e.IdUser, e.IdUserRole });
});
2022-04-11 18:00:34 +05:00
modelBuilder.Entity<RelationUserRolePermission>(entity =>
{
entity.HasKey(e => new { e.IdUserRole, e.IdPermission });
entity.HasOne(r => r.Permission)
.WithMany(p => p.RelationUserRolePermissions)
.IsRequired();
entity.HasOne(r => r.UserRole)
.WithMany(r => r.RelationUserRolePermissions)
.IsRequired();
});
modelBuilder.Entity<DailyReport>(entity =>
{
entity.HasIndex(e => new { e.IdWell, e.Date })
.IsUnique();
2024-06-26 10:58:59 +05:00
entity.Property(e => e.SubsystemBlock)
.HasJsonConversion();
entity.Property(e => e.SignBlock)
.HasJsonConversion();
entity.Property(e => e.TimeBalanceBlock)
.HasJsonConversion();
});
modelBuilder.Entity<DetectedOperation>(entity => entity
2024-06-26 10:58:59 +05:00
.Property(p => p.ExtraData)
.HasJsonConversion());
modelBuilder.Entity<TelemetryDataSaubStat>(entity =>
{
entity.HasNoKey()
.ToView("mw_telemetry_datas_saub_stat");
});
modelBuilder.Entity<Schedule>(entity =>
2022-05-25 20:19:08 +05:00
{
entity.HasOne(d => d.Driller)
.WithMany(p => p.Schedule)
.HasForeignKey(d => d.IdDriller)
.HasConstraintName("t_schedule_t_driller_id_driller");
});
2024-06-26 10:58:59 +05:00
modelBuilder.Entity<SetpointsRequest>(entity =>
{
entity.Property(e => e.Setpoints)
.HasJsonConversion();
});
modelBuilder.Entity<WitsItemFloat>(entity =>
{
2023-03-28 01:05:15 +05:00
entity.HasKey(
nameof(ITelemetryData.IdTelemetry),
2023-03-31 11:10:16 +05:00
nameof(WitsItemBase<float>.IdRecord),
2023-04-07 17:58:46 +05:00
nameof(WitsItemBase<float>.IdItem),
nameof(WitsItemBase<float>.DateTime));
2024-06-26 10:58:59 +05:00
});
modelBuilder.Entity<WitsItemInt>(entity =>
2023-03-29 00:06:16 +05:00
{
entity.HasKey(
nameof(ITelemetryData.IdTelemetry),
2023-03-31 11:10:16 +05:00
nameof(WitsItemBase<int>.IdRecord),
2023-04-07 17:58:46 +05:00
nameof(WitsItemBase<int>.IdItem),
nameof(WitsItemBase<int>.DateTime));
2023-03-29 00:06:16 +05:00
});
modelBuilder.Entity<WitsItemString>(entity =>
2023-03-29 00:06:16 +05:00
{
entity.HasKey(
nameof(ITelemetryData.IdTelemetry),
2023-03-31 11:10:16 +05:00
nameof(WitsItemBase<string>.IdRecord),
2023-04-07 17:58:46 +05:00
nameof(WitsItemBase<string>.IdItem),
nameof(WitsItemBase<string>.DateTime));
2023-03-28 01:05:15 +05:00
});
modelBuilder.Entity<UserSetting>(entity =>
{
entity.HasKey(nameof(UserSetting.IdUser), nameof(UserSetting.Key));
});
modelBuilder.Entity<WellFinalDocument>(entity =>
{
entity.HasKey(x => new { x.IdWell, x.IdUser, x.IdCategory })
.HasName("t_well_final_documents_pk");
});
modelBuilder.Entity<RelationContactWell>(entity =>
{
entity.HasKey(x => new { x.IdWell, x.IdUser });
});
modelBuilder.Entity<ManualDirectory>()
.HasOne(mf => mf.Parent)
.WithMany(mf => mf.Children)
.HasForeignKey(mf => mf.IdParent)
.OnDelete(DeleteBehavior.Cascade);
2024-06-26 10:58:59 +05:00
modelBuilder.Entity<Manual>()
.HasOne(m => m.Directory)
.WithMany(f => f.Manuals)
.HasForeignKey(m => m.IdDirectory)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<DrillTest>()
.HasKey(m => new { m.Id, m.IdTelemetry });
2023-10-17 15:05:58 +05:00
modelBuilder.Entity<DrillTest>(entity =>
{
entity.Property(e => e.Params)
.HasJsonConversion();
});
modelBuilder.Entity<WellSectionPlan>()
.HasIndex(w => new { w.IdWell, w.IdSectionType })
.IsUnique();
modelBuilder.Entity<ProcessMapPlanRotor>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanSlide>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-24 16:05:45 +05:00
modelBuilder.Entity<ProcessMapPlanOperationReamingRotor>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOperationReamingSlide>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-24 16:45:58 +05:00
modelBuilder.Entity<ProcessMapPlanOperationLoadCapacity>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanSurvey>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOperationPositioningOffTheBottom>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOscillationAngles>()
2024-06-26 10:58:59 +05:00
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-25 15:22:32 +05:00
modelBuilder.Entity<ProcessMapPlanOperationTFOrientation>()
2024-06-26 10:58:59 +05:00
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-25 15:22:32 +05:00
modelBuilder.Entity<ProcessMapPlanOperationSwitchPump>()
2024-06-26 10:58:59 +05:00
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOperationSwitchingToTheMode>()
2024-06-26 10:58:59 +05:00
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-29 21:50:28 +05:00
modelBuilder.Entity<ProcessMapPlanDrillTest>()
2024-06-26 10:58:59 +05:00
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-26 11:42:10 +05:00
modelBuilder.Entity<ProcessMapPlanFunctionsShockTest>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-26 13:01:06 +05:00
modelBuilder.Entity<ProcessMapPlanFunctionsDamper>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-29 21:32:53 +05:00
modelBuilder.Entity<ProcessMapPlanAutoHoldTF>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanFunctionsJarrDrillTool>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanUpdatingNoloadParameters>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-29 21:26:43 +05:00
modelBuilder.Entity<ProcessMapPlanOscillation>()
2024-06-26 16:17:19 +05:00
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanAntiCrashRotation>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanStaticMeasurementOutput>()
.HasOne(p => p.Author)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanRotor>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanSlide>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-24 16:05:45 +05:00
modelBuilder.Entity<ProcessMapPlanOperationReamingRotor>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOperationReamingSlide>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-24 16:45:58 +05:00
modelBuilder.Entity<ProcessMapPlanOperationLoadCapacity>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanSurvey>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOperationPositioningOffTheBottom>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOscillationAngles>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-25 15:22:32 +05:00
modelBuilder.Entity<ProcessMapPlanOperationTFOrientation>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOperationSwitchPump>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanOperationSwitchingToTheMode>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-29 21:50:28 +05:00
modelBuilder.Entity<ProcessMapPlanDrillTest>()
2024-06-26 10:58:59 +05:00
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-26 11:42:10 +05:00
modelBuilder.Entity<ProcessMapPlanFunctionsShockTest>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-26 13:01:06 +05:00
modelBuilder.Entity<ProcessMapPlanFunctionsDamper>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-29 21:32:53 +05:00
modelBuilder.Entity<ProcessMapPlanAutoHoldTF>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanFunctionsJarrDrillTool>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanUpdatingNoloadParameters>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
2024-06-29 21:26:43 +05:00
modelBuilder.Entity<ProcessMapPlanOscillation>()
2024-06-26 16:17:19 +05:00
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanAntiCrashRotation>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<ProcessMapPlanStaticMeasurementOutput>()
.HasOne(p => p.Editor)
.WithMany()
.OnDelete(DeleteBehavior.Restrict);
DefaultData.DefaultContextData.Fill(modelBuilder);
}
2022-07-04 17:33:32 +05:00
public Task<int> RefreshMaterializedViewAsync<TEntity>(CancellationToken token)
where TEntity : class
{
2022-07-04 17:33:32 +05:00
var materializedViewName = Set<TEntity>().EntityType.GetViewName()
?? throw new System.Exception($"RefreshMaterializedViewAsync<{typeof(TEntity).Name}>(..) db table for this type does not found.");
return RefreshMaterializedViewAsync(materializedViewName, token);
}
2022-07-04 17:33:32 +05:00
public Task<int> RefreshMaterializedViewAsync(string materializedViewName, CancellationToken token)
{
var sql = $"REFRESH MATERIALIZED VIEW {materializedViewName};";
return Database.ExecuteSqlRawAsync(sql, token);
2024-06-26 10:58:59 +05:00
}
}
}