ConflictResolutionPolicy Class

Definition

Represents the conflict resolution policy configuration for specifying how to resolve conflicts in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service.

public sealed class ConflictResolutionPolicy : Microsoft.Azure.Documents.JsonSerializable
type ConflictResolutionPolicy = class
    inherit JsonSerializable
Public NotInheritable Class ConflictResolutionPolicy
Inherits JsonSerializable
Inheritance
System.Object
ConflictResolutionPolicy

Examples

A collection with custom conflict resolution with no user-registered stored procedure.

var collectionSpec = new DocumentCollection { Id = "Multi-master collection", ConflictResolutionPolicy policy = new ConflictResolutionPolicy { Mode = ConflictResolutionMode.Custom } }; DocumentCollection collection = await client.CreateDocumentCollectionAsync(databaseLink, collectionSpec });

A collection with custom conflict resolution with a user-registered stored procedure.

var collectionSpec = new DocumentCollection { Id = "Multi-master collection", ConflictResolutionPolicy policy = new ConflictResolutionPolicy { Mode = ConflictResolutionMode.Custom, ConflictResolutionProcedure = "conflictResolutionSprocName" } }; DocumentCollection collection = await client.CreateDocumentCollectionAsync(databaseLink, collectionSpec });

A collection with last writer wins conflict resolution, based on a path in the conflicting documents.

var collectionSpec = new DocumentCollection { Id = "Multi-master collection", ConflictResolutionPolicy policy = new ConflictResolutionPolicy { Mode = ConflictResolutionMode.LastWriterWins, ConflictResolutionPath = "/path/for/conflict/resolution" } }; DocumentCollection collection = await client.CreateDocumentCollectionAsync(databaseLink, collectionSpec });

Constructors

ConflictResolutionPolicy()

Initializes a new instance of the ConflictResolutionPolicy class for the Azure Cosmos DB service.

Properties

ConflictResolutionPath

Gets or sets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution. This path must be present in each document and must be an integer value. In case of a conflict occuring on a document, the document with the higher integer value in the specified path will be picked. If the path is unspecified, by default the Timestamp path will be used.

ConflictResolutionProcedure

Gets or sets the StoredProcedure which is used for conflict resolution in the Azure Cosmos DB service. This stored procedure may be created after the DocumentCollection is created and can be changed as required.

Mode

Gets or sets the ConflictResolutionMode in the Azure Cosmos DB service. By default it is LastWriterWins.

Methods

LoadFrom(JsonReader)

Loads the object from the specified JSON reader in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
LoadFrom(JsonReader, JsonSerializerSettings)

Loads the object from the specified JSON reader in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
SaveTo(Stream, SerializationFormattingPolicy)

Saves the object to the specified stream in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
SaveTo(Stream, SerializationFormattingPolicy, JsonSerializerSettings)

Saves the object to the specified stream in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
ToString()

Returns the string representation of the object in the Azure Cosmos DB service.

(Inherited from JsonSerializable)

Applies to