using IRaCIS.Core.Domain.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;


namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
{
    public class TrialSiteSurveyConfigration : IEntityTypeConfiguration<TrialSiteSurvey>
    {
       

        public void Configure(EntityTypeBuilder<TrialSiteSurvey> builder)
        {
            // SubjectVisit 从TrialSite 导航获取 TrialSiteCode  用两个键连接
            builder
            .HasOne(s => s.TrialSite)
            .WithMany(c => c.TrialSiteSurveyList)
            .HasForeignKey(s => new { s.TrialId, s.SiteId })
            .HasPrincipalKey(c => new { c.TrialId, c.SiteId });


            // 从 SubjectVisit  到 TrialSiteUserList   会用两个建 这里不行，添加受试者的时候，批量添加访视的时候，siteId trialId 会重复 所以不能这样搞
            // modelBuilder.Entity<SubjectVisit>()
            //.HasMany(s => s.TrialSiteUserList)
            //.WithOne(c => c.SubjectVisit)
            //.HasForeignKey(s => new { s.TrialId, s.SiteId })
            //.HasPrincipalKey(c => new { c.TrialId, c.SiteId });

        }
    }
}
