Exemple #1
0
        private void FixupDemographic(Demographic previousValue)
        {
            // This is the principal end in an association that performs cascade deletes.
            // Update the event listener to refer to the new dependent.
            if (previousValue != null)
            {
                ChangeTracker.PropertyChanged -= previousValue.HandleCascadeDelete;
            }

            if (Demographic != null)
            {
                ChangeTracker.PropertyChanged += Demographic.HandleCascadeDelete;
            }

            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && ReferenceEquals(previousValue.Customer, this))
            {
                previousValue.Customer = null;
            }

            if (Demographic != null)
            {
                Demographic.Customer = this;
            }

            if (ChangeTracker.IsChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("Demographic") &&
                    ReferenceEquals(ChangeTracker.OriginalValues["Demographic"], Demographic))
                {
                    //ChangeTracker.OriginalValues.Remove("Demographic");
                }
                else
                {
                    //RecordOriginalValue("Demographic", previousValue);
                    // This is the principal end of an identifying association, so the dependent must be deleted when the relationship is removed.
                    // If the current state of the dependent is Added, the relationship can be changed without causing the dependent to be deleted.
                    if (previousValue != null && previousValue.ChangeTracker.State != ObjectState.Added)
                    {
                        previousValue.MarkAsDeleted();
                    }
                }
                if (Demographic != null && !Demographic.ChangeTracker.IsChangeTrackingEnabled)
                {
                    Demographic.StartTracking();
                }
            }
        }
Exemple #2
0
 partial void DemographicChanged(Demographic previousValue);
Exemple #3
0
 partial void DemographicChanging(Demographic newValue);