Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 0.51 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Handling Contraints And Identifiers In A Custom Object Model For Persisting To A Relational Database
  2. class Foo
  3. {
  4.     public int Id { get; set; }
  5.     public int BarId { get; set; }
  6.     Bar _bar;
  7.     public Bar Bar
  8.     {
  9.         get { return _bar; }
  10.         set
  11.         {
  12.             if(_bar != value)
  13.             {
  14.                  _bar = value;
  15.                  BarId = value.Id;
  16.             }
  17.         }
  18.      }
  19. }
  20.  
  21. class Bar
  22. {
  23.     public int Id { get; set; }
  24. }
  25.        
  26. var f = new Foo() { Bar = new Bar() };
  27. SaveFoo(f);