44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using IRaCIS.Core.Domain.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
|
|
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
|
{
|
|
public class StudyConfigration : IEntityTypeConfiguration<DicomStudy>
|
|
{
|
|
|
|
/// <summary>
|
|
/// 一个外键,关联多个表
|
|
/// </summary>
|
|
/// <param name="builder"></param>
|
|
public void Configure(EntityTypeBuilder<DicomStudy> builder)
|
|
{
|
|
|
|
builder
|
|
.HasMany(s => s.ReadingClinicalDataList)
|
|
.WithOne(c => c.DicomStudy)
|
|
.HasForeignKey(s => new { s.StudyId })
|
|
.HasPrincipalKey(c => new { c.Id });
|
|
|
|
|
|
builder
|
|
.HasMany(s => s.ReadingConsistentClinicalDataList)
|
|
.WithOne(c => c.DicomStudy)
|
|
.HasForeignKey(s => new { s.StudyId })
|
|
.HasPrincipalKey(c => new { c.Id });
|
|
|
|
}
|
|
}
|
|
|
|
public class ReadModuleConfigration : IEntityTypeConfiguration<ReadModule>
|
|
{
|
|
|
|
public void Configure(EntityTypeBuilder<ReadModule> builder)
|
|
{
|
|
|
|
builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList).HasForeignKey(t => t.SubjectVisitId);
|
|
}
|
|
}
|
|
}
|