考虑这些表。耦合表为TAGREGISTRATION
,在PATIENT
和TAGREGISTRATION
之间是1:1关系,在TAG
和TAGREGISTRATION
之间是1:1关系
PATIENT
----------
PK ID int
NAME varchar(255)
TAG
----------
PK ID int
NAME varchar(255)
TAGREGISTRATION
----------
PK ID int
FK PATIENT_ID int
FK TAG_ID int
PatientDto
和TagDto
的CRUD操作的实体和相应的DTO看起来如何?
仅供参考:使用AutoMapper,NHibernate和FluentNHibernate。
public class Patient : Entity
{
public virtual string Name { get; set; }
}
public class Tag : Entity
{
public virtual string Name { get; set; }
}
public class TagRegistration : Entity
{
public virtual Tag Tag { get; set; }
public virtual Patient Patient { get; set; }
}
public class PatientDto
{
public int Id { get; set; }
public string Name { get; set; }
public TagDto Tag { get; set; }
}
public class TagDto
{
public int Id { get; set; }
public string Name { get; set; }
}
public class TagRegistrationDto
{
public int Id { get; set; }
public TagDto Tag { get; set; }
public PatientDto Patient { get; set; }
}