Пример #1
0
        private void FixupShippers(Shippers previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

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

            if (Shippers != null)
            {
                if (!Shippers.Orders.Contains(this))
                {
                    Shippers.Orders.Add(this);
                }

                ShipVia = Shippers.ShipperID;
            }
            else if (!skipKeys)
            {
                ShipVia = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Shippers") &&
                    (ChangeTracker.OriginalValues["Shippers"] == Shippers))
                {
                    ChangeTracker.OriginalValues.Remove("Shippers");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Shippers", previousValue);
                }
                if (Shippers != null && !Shippers.ChangeTracker.ChangeTrackingEnabled)
                {
                    Shippers.StartTracking();
                }
            }
        }
Пример #2
0
        private void FixupShippers(Shippers previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

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

            if (Shippers != null)
            {
                if (!Shippers.Orders.Contains(this))
                {
                    Shippers.Orders.Add(this);
                }

                ShipVia = Shippers.ShipperID;
            }
            else if (!skipKeys)
            {
                ShipVia = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Shippers")
                    && (ChangeTracker.OriginalValues["Shippers"] == Shippers))
                {
                    ChangeTracker.OriginalValues.Remove("Shippers");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("Shippers", previousValue);
                }
                if (Shippers != null && !Shippers.ChangeTracker.ChangeTrackingEnabled)
                {
                    Shippers.StartTracking();
                }
            }
        }