I have a PersonEntity, an AddressEntity and a PersonAddress join table (with the two FKs plus an AddressType field).
At runtime I want to use databinding to an address of a particular type, say HomeAddress, so I have a property called HomeAddress which looks in the join table for an address of type HomeAddress and returns it if found.
If it isn't found, I need to create one on the fly so that databinding will work. This involves a new PersonAddressEntity and a new AddressEntity.
If the user doesn't change anything in the new AddressEntity then its IsDirty flag is false and so won't get saved which is great.
However the intermediate PersonAddressEntity is a problem. If I set its IsDirty flag to false, then it doesn't get saved though its AddressEntity will (if modified). If I leave it as true but the user doesn't make a change to AddressEntity then it bombs because it has no AddressID to use.
Any ideas on what I can do to make PersonAddress.IsDirty 'conditional' on its Address.IsDirty?