ConstraintConflictReason Enumeration

Represents the reasons that a constraint conflict can occur.

Namespace: Microsoft.Synchronization
Assembly: Microsoft.Synchronization (in microsoft.synchronization.dll)

Syntax

'Declaration
Public Enumeration ConstraintConflictReason
'Usage
Dim instance As ConstraintConflictReason
public enum ConstraintConflictReason
public enum class ConstraintConflictReason
public enum ConstraintConflictReason
public enum ConstraintConflictReason

Members

  Member name Description
Collision The item cannot be saved because it conflicts with another item in the store, such as an item that has the same name as an existing item. The provider must specify the ID of the destination item as the conflicting item ID. 
Identity The source replica and the destination replica disagree about the identity of an item. For example, replica X resolves a collision conflict between items with IDs id1 and id2 by merging the items and assigning id1 to the merged item. Replica Y resolves a collision conflict between items with IDs id1 and id2 by renaming the item identified by id1 and keeping both items. Replica X sends the merged item identified by id1 and a merge tombstone that indicates that id2 has been merged into id1. The conflict on id1 is detected and resolved as a concurrency conflict. The conflict on id2 is detected and reported to the synchronization application as an identity conflict by specifying a conflict reason of Identity. The application determines whether to resolve the conflict by keeping the source change or the destination change.  
NoParent The item cannot be saved in the hierarchical data store because the item requires a parent item that does not exist in the store. The provider can optionally specify the ID of the missing parent as the conflicting item ID. 
Other The item or change unit violates some other constraint of the destination replica. The provider can optionally specify the ID of the conflicting item as the conflicting item ID. 

Remarks

The destination provider uses a member of ConstraintConflictReason to specify the reason for a constraint conflict when it reports a constraint conflict to the change applier. For more information on constraint conflicts, see Detecting and Resolving Constraint Conflicts.

Example

The following example detects whether a newly created item causes a constraint conflict, and returns the appropriate constraint conflict reason when it does.

Public Function CanCreateContact(ByVal itemChange As ItemChange, ByVal changeData As String(), ByRef reason As ConstraintConflictReason, ByRef conflictingItemId As SyncId) As Boolean
    Dim canCreate As Boolean = True

    ' Create a temporary contact and see if its index values conflict with any item already in the contact store.
    Dim newContact As New Contact(changeData)
    canCreate = Not DetectIndexCollision(newContact, conflictingItemId)
    If Not canCreate Then
        ' An index collision occurred, so report a collision conflict.
        reason = ConstraintConflictReason.Collision
    Else
        ' This value won't be used because canCreate is set to true in this case.
        reason = ConstraintConflictReason.Other
    End If

    Return canCreate
End Function
public bool CanCreateContact(ItemChange itemChange, string[] changeData, out ConstraintConflictReason reason, out SyncId conflictingItemId)
{
    bool canCreate = true;

    // Create a temporary contact and see if its index values conflict with any item already in the contact store.
    Contact newContact = new Contact(changeData);
    canCreate = !DetectIndexCollision(newContact, out conflictingItemId);
    if (!canCreate)
    {
        // An index collision occurred, so report a collision conflict.
        reason = ConstraintConflictReason.Collision;
    }
    else
    {
        // This value won't be used because canCreate is set to true in this case.
        reason = ConstraintConflictReason.Other;
    }

    return canCreate;
}

See Also

Reference

Microsoft.Synchronization Namespace