예제 #1
0
        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();
                }
            }
        }