Guest User

Untitled

a guest
Jul 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. public List<Patient> GetAllPatients()
  2. {
  3. try
  4. {
  5. using (OptoEntities db = new OptoEntities())
  6. {
  7. List<Patient> list = db.Patients
  8. .Include("Addresses")
  9. .Include("PhoneNumbers")
  10. .Include("Examinations").ToList();
  11.  
  12. list.ForEach(p =>
  13. {
  14. p.ChangeTracker.ChangeTrackingEnabled = true;
  15.  
  16. if (!p.Addresses.IsNull() &&
  17. p.Addresses.Count > 0)
  18. p.Addresses.ForEach(a => a.ChangeTracker.ChangeTrackingEnabled = true);
  19.  
  20. if (!p.PhoneNumbers.IsNull() &&
  21. p.PhoneNumbers.Count > 0)
  22. p.PhoneNumbers.ForEach(a => a.ChangeTracker.ChangeTrackingEnabled = true);
  23.  
  24. if (!p.Examinations.IsNull() &&
  25. p.Examinations.Count > 0)
  26. p.Examinations.ForEach(e =>
  27. {
  28. e.ChangeTracker.ChangeTrackingEnabled = true;
  29.  
  30. });
  31. });
  32.  
  33. return list;
  34. }
  35. }
  36. catch (Exception ex)
  37. {
  38. return new List<Patient>();
  39. }
  40. }
Add Comment
Please, Sign In to add comment