Ejemplo n.º 1
0
     private void FixupPaymentInfo(BookingPayment 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.ObjectStateChanging -= previousValue.HandleCascadeDelete;
         }
 
         if (PaymentInfo != null)
         {
             ChangeTracker.ObjectStateChanging += PaymentInfo.HandleCascadeDelete;
         }
 
         if (IsDeserializing)
         {
             return;
         }
 
         if (PaymentInfo != null)
         {
             PaymentInfo.BookingId = Id;
         }
 
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("PaymentInfo")
                 && (ChangeTracker.OriginalValues["PaymentInfo"] == PaymentInfo))
             {
                 ChangeTracker.OriginalValues.Remove("PaymentInfo");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("PaymentInfo", 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 (PaymentInfo != null && !PaymentInfo.ChangeTracker.ChangeTrackingEnabled)
             {
                 PaymentInfo.StartTracking();
             }
         }
     }