private void FixupAddress1(Address previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.SalesOrderHeaders1.Contains(this))
            {
                previousValue.SalesOrderHeaders1.Remove(this);
            }

            if (Address1 != null)
            {
                if (!Address1.SalesOrderHeaders1.Contains(this))
                {
                    Address1.SalesOrderHeaders1.Add(this);
                }

                ShipToAddressID = Address1.AddressID;
            }
            else if (!skipKeys)
            {
                ShipToAddressID = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Address1")
                    && (ChangeTracker.OriginalValues["Address1"] == Address1))
                {
                    ChangeTracker.OriginalValues.Remove("Address1");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Address1", previousValue);
                }
                if (Address1 != null && !Address1.ChangeTracker.ChangeTrackingEnabled)
                {
                    Address1.StartTracking();
                }
            }
        }
Example #2
0
     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();
             }
         }
     }