我有我的數據訪問類的代碼,我想加載所有患者,他們應該有,Patient.Addresses,Patient.Examinations,Examinations.LeftEye,Examinations.RightEye。 ...實體框架4.0自我跟蹤加載導航屬性
如何將所有相關數據加載到患者身上?我還沒有設法加載地址。
這是當前的代碼:
db.Patients.Include("Addresses");
db.Patients.Include("Examinations");
db.Examinations.Include("LeftEyePictures");
db.Examinations.Include("RightEyePictures");
List<Patient> list = db.Patients.ToList();
list.ForEach(p => p.ChangeTracker.ChangeTrackingEnabled = true);
return list;
謝謝。
這是我的第一種方法,我是否使用導航屬性名稱設置了包含字符串參數的權利?或模型表的名稱? –
它迄今爲止工作.... Thanx –
您必須使用導航屬性的名稱。 –