我想展示患者各自的DoctorNote,Album和PatientAllocation Table。我如何使用模型将它们连接在一起。
Patient Table
Primary key: patientID
PatientAllocation Table
Primary key: patientAllocationID
Foreign Key: patientID
DoctorNote Table
Foreign Key: patientID
Album Table
Foreign Key: AlbumID
我如何使用模型将所有模型连接在一起,或者这是不可能的。目前这是我为DoctorNote所做的。由于DoctorNote表包含外键patientID。模型将映射并显示结果。
[HttpGet]
[Route("api/PatientListPage/DoctorNoteDetails_XML")]
public IHttpActionResult DoctorNoteDetails_XML()
{
var DoctorNoteDetails = Ok(_context.DoctorNotes.Include(x => x.patientID).ToList().Select((Mapper.Map<DoctorNote, DoctorNoteDto>));
return DoctorNoteDetails;
}
答案 0 :(得分:0)
public class Patient: IPatient
{
public int patientId {get;set;}
public IPatientAllocation PatientAllocations {get;set;}
public IDoctorNote DoctorNotes {get;set;}
}
public class PatientAllocation: IPatientAllocation
{
public int PatientAllocationId {get;set;}
public IPatient Patients {get;set;}
}
public class DoctorNote: IDoctorNote
{
public IPatient Patients {get;set;}
}