- Handling Contraints And Identifiers In A Custom Object Model For Persisting To A Relational Database
- class Foo
- {
- public int Id { get; set; }
- public int BarId { get; set; }
- Bar _bar;
- public Bar Bar
- {
- get { return _bar; }
- set
- {
- if(_bar != value)
- {
- _bar = value;
- BarId = value.Id;
- }
- }
- }
- }
- class Bar
- {
- public int Id { get; set; }
- }
- var f = new Foo() { Bar = new Bar() };
- SaveFoo(f);