耦合表的NHibernate映射

时间:2018-07-25 09:27:39

标签: c# nhibernate

考虑这些表。耦合表为TAGREGISTRATION,在PATIENTTAGREGISTRATION之间是1:1关系,在TAGTAGREGISTRATION之间是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

PatientDtoTagDto的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; }
}

0 个答案:

没有答案