Files
Backend-Api/CompanyManagment.EFCore/Mapping/PersonalContractingpartyMapping.cs

62 lines
2.6 KiB
C#

using System;
using _0_Framework.Application;
using Company.Domain.ContarctingPartyAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class PersonalContractingpartyMapping : IEntityTypeConfiguration<PersonalContractingParty>
{
public void Configure(EntityTypeBuilder<PersonalContractingParty> builder)
{
builder.ToTable("PersonalContractingParties");
builder.HasKey(x => x.id);
//builder.Property(x => x.LegalName).HasMaxLength(255).IsRequired();
builder.Property(x => x.FName).HasMaxLength(150).IsRequired();
builder.Property(x => x.LName).HasMaxLength(150).IsRequired();
builder.Property(x => x.SureName).HasMaxLength(50).IsRequired(false);
builder.Property(x => x.Nationalcode).HasMaxLength(10).IsRequired();
builder.Property(x => x.IdNumber).HasMaxLength(20).IsRequired(false);
builder.Property(x => x.RepresentativeFullName).HasMaxLength(50);
builder.Property(x => x.RegisterId).HasMaxLength(15).IsRequired();
builder.Property(x => x.NationalId).HasMaxLength(15).IsRequired();
builder.Property(x => x.IsLegal).HasMaxLength(10).IsRequired();
builder.Property(x => x.State).HasMaxLength(50);
builder.Property(x => x.City).HasMaxLength(50);
builder.Property(x => x.Zone).HasMaxLength(50);
builder.Property(x => x.Address).HasMaxLength(500);
builder.Property(x => x.Phone).HasMaxLength(50);
builder.Property(x => x.AgentPhone).HasMaxLength(50);
builder.Property(x => x.IsActiveString).HasMaxLength(5);
builder.Property(x => x.IsBlock).HasMaxLength(5);
builder.Property(x => x.BlockTimes);
#region NewProp
builder.Property(x => x.IdNumberSeri).HasMaxLength(5);
builder.Property(x => x.IdNumberSerial).HasMaxLength(15);
builder.Property(x => x.FatherName).HasMaxLength(20);
builder.Property(x => x.DateOfBirth).IsRequired(false);
builder.Property(x => x.Gender).HasConversion(
v => v.ToString(),
v => string.IsNullOrWhiteSpace(v) ? Gender.None : (Gender)Enum.Parse(typeof(Gender), v)).HasMaxLength(6);
builder.Property(x=>x.LegalPosition).HasMaxLength(50);
#endregion
builder.HasMany(x => x.Employers)
.WithOne(x => x.ContractingParty)
.HasForeignKey(x => x.ContractingPartyId);
//child < Representative
builder.HasOne(x => x.Representative)
.WithMany(x => x.ContractingParties)
.HasForeignKey(x => x.RepresentativeId);
}
}