Fix WellComposite model FK; WellCompositeService automapping

Rename DrillFlowChartParams to DrillFlowChart
This commit is contained in:
Фролов 2021-10-14 14:46:20 +05:00
parent aa977e4db5
commit 91878bda5c
8 changed files with 5502 additions and 13 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace AsbCloudDb.Migrations
{
public partial class Fix_WellComposite_FK : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "t_well_сomposite_t_well_section_type_id_fk",
table: "t_well_сomposite");
migrationBuilder.CreateIndex(
name: "IX_t_well_сomposite_id_well_section_type",
table: "t_well_сomposite",
column: "id_well_section_type");
migrationBuilder.AddForeignKey(
name: "t_well_сomposite_t_well_section_type_id_fk",
table: "t_well_сomposite",
column: "id_well_section_type",
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "t_well_сomposite_t_well_section_type_id_fk",
table: "t_well_сomposite");
migrationBuilder.DropIndex(
name: "IX_t_well_сomposite_id_well_section_type",
table: "t_well_сomposite");
migrationBuilder.AddForeignKey(
name: "t_well_сomposite_t_well_section_type_id_fk",
table: "t_well_сomposite",
column: "id_well_src",
principalTable: "t_well_section_type",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace AsbCloudDb.Migrations
{
public partial class Rename_DrillFlowChartParams_to_DrillFlowChart : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_drill_flow_chart_params_t_well_well_id",
table: "t_drill_flow_chart_params");
migrationBuilder.DropPrimaryKey(
name: "PK_t_drill_flow_chart_params",
table: "t_drill_flow_chart_params");
migrationBuilder.RenameTable(
name: "t_drill_flow_chart_params",
newName: "t_drill_flow_chart");
migrationBuilder.RenameIndex(
name: "IX_t_drill_flow_chart_params_well_id",
table: "t_drill_flow_chart",
newName: "IX_t_drill_flow_chart_well_id");
migrationBuilder.AddPrimaryKey(
name: "PK_t_drill_flow_chart",
table: "t_drill_flow_chart",
column: "id");
migrationBuilder.AddForeignKey(
name: "FK_t_drill_flow_chart_t_well_well_id",
table: "t_drill_flow_chart",
column: "well_id",
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_drill_flow_chart_t_well_well_id",
table: "t_drill_flow_chart");
migrationBuilder.DropPrimaryKey(
name: "PK_t_drill_flow_chart",
table: "t_drill_flow_chart");
migrationBuilder.RenameTable(
name: "t_drill_flow_chart",
newName: "t_drill_flow_chart_params");
migrationBuilder.RenameIndex(
name: "IX_t_drill_flow_chart_well_id",
table: "t_drill_flow_chart_params",
newName: "IX_t_drill_flow_chart_params_well_id");
migrationBuilder.AddPrimaryKey(
name: "PK_t_drill_flow_chart_params",
table: "t_drill_flow_chart_params",
column: "id");
migrationBuilder.AddForeignKey(
name: "FK_t_drill_flow_chart_params_t_well_well_id",
table: "t_drill_flow_chart_params",
column: "well_id",
principalTable: "t_well",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -156,7 +156,7 @@ namespace AsbCloudDb.Migrations
.HasComment("Месторождение");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChartParams", b =>
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -238,7 +238,7 @@ namespace AsbCloudDb.Migrations
b.HasIndex("IdWell");
b.ToTable("t_drill_flow_chart_params");
b.ToTable("t_drill_flow_chart");
b
.HasComment("Параметры корридоров бурения (диапазоны параметров бурения)");
@ -1679,6 +1679,8 @@ namespace AsbCloudDb.Migrations
b.HasKey("IdWell", "IdWellSrc", "IdWellSectionType");
b.HasIndex("IdWellSectionType");
b.HasIndex("IdWellSrc");
b.ToTable("t_well_сomposite");
@ -2296,7 +2298,7 @@ namespace AsbCloudDb.Migrations
b.Navigation("CompanyType");
});
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChartParams", b =>
modelBuilder.Entity("AsbCloudDb.Model.DrillFlowChart", b =>
{
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany()
@ -2542,6 +2544,13 @@ namespace AsbCloudDb.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
.WithMany("WellComposites")
.HasForeignKey("IdWellSectionType")
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.Well", "WellSrc")
.WithMany("WellCompositeSrcs")
.HasForeignKey("IdWellSrc")
@ -2549,13 +2558,6 @@ namespace AsbCloudDb.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("AsbCloudDb.Model.WellSectionType", "WellSectionType")
.WithMany("WellComposites")
.HasForeignKey("IdWellSrc")
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Well");
b.Navigation("WellSectionType");

View File

@ -92,7 +92,7 @@ namespace AsbCloudDb.Model
entity.HasOne(d => d.WellSectionType)
.WithMany(p => p.WellComposites)
.HasForeignKey(d => d.IdWellSrc)
.HasForeignKey(d => d.IdWellSectionType)
.HasConstraintName("t_well_сomposite_t_well_section_type_id_fk");
});

View File

@ -6,7 +6,7 @@ using System.Text.Json.Serialization;
namespace AsbCloudDb.Model
{
[Table("t_drill_flow_chart_params"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")]
[Table("t_drill_flow_chart"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")]
public class DrillFlowChart : IId
{
[Key]

View File

@ -35,8 +35,10 @@ namespace AsbCloudInfrastructure.Services
{
context.WellComposites.RemoveRange(context.WellComposites
.Where(c => c.IdWell == idWell));
var entities = wellComposites
.Adapt<WellComposite>(s => s.IdWell = idWell);
.Adapt<WellComposite, WellCompositeDto>((s, d) => { s.IdWell = idWell; });
context.WellComposites.AddRange(entities);
return context.SaveChangesAsync(token);
}