sdk/dotnet/src/Microsoft.Datasync.Client/Offline/Queue/InsertOperation.cs
/// <summary>
/// Validates that the operation can collapse with a new operation.
/// </summary>
/// <param name="newOperation">The new operation.</param>
/// <exception cref="InvalidOperationException">when the operation cannot collapse with the new operation.</exception>
Validates that the operation can collapse with a new operation.
Validates that the operation can collapse with a new operation .
public override void ValidateOperationCanCollapse(TableOperation newOperation)
        {
            if (newOperation.ItemId != ItemId)
            {
                throw new ArgumentException($"Cannot collapse insert operation '{Id}' with '{newOperation.Id}' - Item IDs do not match", nameof(newOperation));
            }
            if (newOperation is InsertOperation)
            {
                throw new InvalidOperationException($"An insert operation on item '{ItemId}' already exists in the operations queue.");
            }
            if (newOperation is DeleteOperation && State != TableOperationState.Pending)
            {
                throw new InvalidOperationException("Cannot process deletion because there is an in-progress insert operation.  Complete a 'Push' operation first.");
            }
        }
public override void ValidateOperationCanCollapse ( TableOperation newOperation ) { if ( newOperation . ItemId != ItemId ) { throw new ArgumentException ( $" Cannot collapse insert operation ' { Id } ' with ' { newOperation . Id } ' - Item IDs do not match " , nameof ( newOperation ) ) ; } if ( newOperation is InsertOperation ) { throw new InvalidOperationException ( $" An insert operation on item ' { ItemId } ' already exists in the operations queue. " ) ; } if ( newOperation is DeleteOperation && State != TableOperationState . Pending ) { throw new InvalidOperationException ( " " ) ; } }
Validates that the operation can collapse with a new operation.
Validates that the operation can collapse with a new operation .
// Insert followed by an Insert is not allowed. // Insert followed by Delete is allowed, but only if the Insert has not been tried yet. // If it has been tried, it may not have completed successfully, so we have to ensure // a consistent offline state.
when the operation cannot collapse with the new operation.
when the operation cannot collapse with the new operation .
newOperation
TableOperation
The new operation.
The new operation .