Guest User

Untitled

a guest
Jun 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. // The Entity
  2.  
  3. public class MyEntity : EntityBase
  4. {
  5. private IList<SomeKindOfRelatedType> _relatedStuff;
  6.  
  7. public IList<SomeKindOfRelatedType> RelatedStuff
  8. {
  9. get
  10. {
  11. if (relatedStuff == null)
  12. {
  13. relatedStuff = new List<SomeKindOfRelatedType>();
  14. }
  15. if (!IsNew)
  16. {
  17. this.Initialize(/*x, y, z*/);
  18. }
  19. return relatedStuff;
  20. }
  21. }
  22.  
  23. private IList<SomeKindOfRelatedType> relatedStuff
  24. {
  25. get { return _relatedStuff; }
  26. set
  27. {
  28. _relatedStuff = value;
  29. OnNotifyPropertyChanged("RelatedStuff");
  30. }
  31. }
  32. }
  33.  
  34. // An extension method defined somewhere else,
  35. // but obviously in the same assembly as the entities
  36. // since it's called from within the entities. :\
  37.  
  38. public static void Initialize(this EntityBase entity, /*x, y, z*/)
  39. {
  40. using (var session = SessionManager.Instance.GetSession())
  41. {
  42. // new transaction
  43. // load data from NH
  44. }
  45. }
Add Comment
Please, Sign In to add comment