public partial class Doctor
{
public Doctor()
{
this.Patients = new HashSet<Patient>();
this.Presriptions = new HashSet<Prescription>();
this.Clinics = new HashSet<Clinic>();
}
public int DoctorId { get; set; }
public string DoctorName { get; set; }
public string Specialist { get; set; }
public virtual ICollection<Clinic> Clinics { get; set; }
}
我们希望使用通用的Repository Get(doctorId)方法检索与该医生相关的所有诊所
var clinics = unitOfWork.ClinincRepository.Get();
答案 0 :(得分:0)
您应该将ClinicDoctorRepository与急切加载一起使用
var clinics = unitOfWork.ClinicDoctorRepository.Include("Clinics").Where(m => m.DoctorId == doctorId).Get();
它将基于ClinicDoctor表中的ClinicsId在ClinicDoctor和Clinics之间进行数据库内连接,并将在ClinicDoctor表中的DocotorId上应用
修改强>
请按照link to msdn
进行操作