Esempio n. 1
0
     private void FixupCountry(Country previousValue)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (Country != null)
         {
             CountryId = Country.Id;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Country")
                 && (ChangeTracker.OriginalValues["Country"] == Country))
             {
                 ChangeTracker.OriginalValues.Remove("Country");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Country", previousValue);
             }
             if (Country != null && !Country.ChangeTracker.ChangeTrackingEnabled)
             {
                 Country.StartTracking();
             }
         }
     }
Esempio n. 2
0
     private void FixupCountry(Country previousValue)
     {
         // This is the dependent end in an association that performs cascade deletes.
         // Update the principal's event listener to refer to the new dependent.
         // This is a unidirectional relationship from the dependent to the principal, so the dependent end is
         // responsible for managing the cascade delete event handler. In all other cases the principal end will manage it.
         if (previousValue != null)
         {
             previousValue.ChangeTracker.ObjectStateChanging -= HandleCascadeDelete;
         }
 
         if (Country != null)
         {
             Country.ChangeTracker.ObjectStateChanging += HandleCascadeDelete;
         }
 
         if (IsDeserializing)
         {
             return;
         }
 
         if (Country != null)
         {
             CountryId = Country.Id;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Country")
                 && (ChangeTracker.OriginalValues["Country"] == Country))
             {
                 ChangeTracker.OriginalValues.Remove("Country");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Country", previousValue);
                 // This is the dependent end of an identifying association, so it must be deleted when the relationship is
                 // removed. If the current state is Added, the relationship can be changed without causing the dependent to be deleted.
                 // This is a unidirectional relationship from the dependent to the principal, so the dependent end is
                 // responsible for cascading the delete. In all other cases the principal end will manage it.
                 if (previousValue != null && ChangeTracker.State != ObjectState.Added)
                 {
                     this.MarkAsDeleted();
                 }
             }
             if (Country != null && !Country.ChangeTracker.ChangeTrackingEnabled)
             {
                 Country.StartTracking();
             }
         }
     }