Guest User

Untitled

a guest
Aug 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Flatten/expand columns of Navigation Property for ViewModel?
  2. class Employee
  3. {
  4. [Key]
  5. public int EmployeeKey {get;set;}
  6.  
  7. public string EmployeeName { get; set; }
  8.  
  9. public int CurrentEmployeeChangeKey { get; set; }
  10. [ForeignKey("CurrentEmployeeChangeKey")]
  11. public virtual EmployeeChange CurrentEmployeeChange {
  12. get { return EmployeeChanges.FirstOrDefault() ; } /*set;*/ }
  13.  
  14. public virtual ICollection<EmployeeChange> EmployeeChanges { get; set; }
  15. }
  16.  
  17. class EmployeeChange
  18. {
  19. [Key]
  20. public int EmployeeChangeKey { get; set; }
  21.  
  22. public int EmployeeKey { get; set; }
  23. [ForeignKey("EmployeeKey")]
  24. public virtual Employee Employee { get; set; }
  25.  
  26.  
  27. public string EmployeeStreet { get; set; }
  28. public string EmployeeCity { get; set; }
  29. public string Etc { get; set; }
  30.  
  31. public DateTime ChangeEffective { get; set; }
  32.  
  33. }
  34.  
  35. class EmployeeCurrentChange
  36. {
  37. public string EmployeeName { get; set; }
  38. public string EmployeeStreet { get; set; }
  39. public string EmployeeCity { get; set; }
  40. public string Etc { get; set; }
  41.  
  42. public DateTime ChangeEffective { get; set; }
  43.  
  44. //I don't need the below properties in the result, but if they
  45. //happen to be there I don't mind.
  46. public int EmployeeKey { get; set; }
  47. [ForeignKey("EmployeeKey")]
  48. public virtual Employee Employee { get; set; }
  49.  
  50. [Key]
  51. public int EmployeeKey {get;set;}
  52.  
  53. public int CurrentEmployeeChangeKey { get; set; }
  54. [ForeignKey("CurrentEmployeeChangeKey")]
  55. public virtual EmployeeChange CurrentEmployeeChange {
  56. get { return EmployeeChanges.FirstOrDefault() ; } /*set;*/ }
  57.  
  58. public virtual ICollection<EmployeeChange> EmployeeChanges { get; set; }
  59.  
  60. [Key]
  61. public int EmployeeChangeKey { get; set; }
  62.  
  63. }
Add Comment
Please, Sign In to add comment