private void FixupAddress(Address previousValue, bool skipKeys = false) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.SalesOrderHeaders.Contains(this)) { previousValue.SalesOrderHeaders.Remove(this); } if (Address != null) { if (!Address.SalesOrderHeaders.Contains(this)) { Address.SalesOrderHeaders.Add(this); } BillToAddressID = Address.AddressID; } else if (!skipKeys) { BillToAddressID = null; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("Address") && (ChangeTracker.OriginalValues["Address"] == Address)) { ChangeTracker.OriginalValues.Remove("Address"); } else { ChangeTracker.RecordOriginalValue("Address", previousValue); } if (Address != null && !Address.ChangeTracker.ChangeTrackingEnabled) { Address.StartTracking(); } } }
private void FixupAddress(Address previousValue) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.CustomerAddresses.Contains(this)) { previousValue.CustomerAddresses.Remove(this); } if (Address != null) { if (!Address.CustomerAddresses.Contains(this)) { Address.CustomerAddresses.Add(this); } AddressID = Address.AddressID; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("Address") && (ChangeTracker.OriginalValues["Address"] == Address)) { ChangeTracker.OriginalValues.Remove("Address"); } else { ChangeTracker.RecordOriginalValue("Address", previousValue); } if (Address != null && !Address.ChangeTracker.ChangeTrackingEnabled) { Address.StartTracking(); } } }