Files
Backend-Api/CompanyManagment.EFCore/Mapping/ClassificationSchemeMapping.cs
2025-09-18 05:16:00 +03:30

38 lines
1.4 KiB
C#

using System;
using _0_Framework.Application.Enums;
using Company.Domain.ClassificationSchemeAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class ClassificationSchemeMapping : IEntityTypeConfiguration<ClassificationScheme>
{
public void Configure(EntityTypeBuilder<ClassificationScheme> builder)
{
builder.ToTable("ClassificationSchemes");
builder.HasKey(x => x.id);
builder.Property(x => x.IncludingDateGr);
builder.Property(x => x.ExecutionDateGr);
builder.Property(x => x.EndSchemeDateGr).IsRequired(false);
builder.Property(x => x.DesignerFullName).HasMaxLength(50);
builder.Property(x => x.DesignerPhone).HasMaxLength(20);
builder.Property(x => x.WorkshopId);
builder.Property(x => x.WorkshopId);
builder.Property(x => x.TypeOfCoefficient).HasConversion(
v => v.ToString(),
v => (TypeOfCoefficient)Enum.Parse(typeof(TypeOfCoefficient), v)).HasMaxLength(30);
builder.HasMany(x => x.ClassificationGroups)
.WithOne(x => x.ClassificationScheme)
.HasForeignKey(x => x.ClassificationSchemeId);
builder.HasMany(x => x.ClassificationRialCoefficients)
.WithOne(x => x.ClassificationScheme)
.HasForeignKey(x => x.ClassificationSchemeId);
}
}