private void FixupAirport(Airport previousValue)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (Airport != null)
         {
             AirportId = Airport.Id;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Airport")
                 && (ChangeTracker.OriginalValues["Airport"] == Airport))
             {
                 ChangeTracker.OriginalValues.Remove("Airport");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Airport", previousValue);
             }
             if (Airport != null && !Airport.ChangeTracker.ChangeTrackingEnabled)
             {
                 Airport.StartTracking();
             }
         }
     }
Exemple #2
0
     private void FixupAirport(Airport 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 (Airport != null)
         {
             Airport.ChangeTracker.ObjectStateChanging += HandleCascadeDelete;
         }
 
         if (IsDeserializing)
         {
             return;
         }
 
         if (Airport != null)
         {
             AirportId = Airport.Id;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Airport")
                 && (ChangeTracker.OriginalValues["Airport"] == Airport))
             {
                 ChangeTracker.OriginalValues.Remove("Airport");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Airport", 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 (Airport != null && !Airport.ChangeTracker.ChangeTrackingEnabled)
             {
                 Airport.StartTracking();
             }
         }
     }