Class Conflicts
Operations for reading/querying conflicts in a Azure Cosmos container.
public abstract class Conflicts
- Inheritance
-
Conflicts
- Inherited Members
- Extension Methods
Constructors
Conflicts()
protected Conflicts()
Methods
DeleteAsync(ConflictProperties, PartitionKey, CancellationToken)
Delete a conflict from the Azure Cosmos service as an asynchronous operation.
public abstract Task<ResponseMessage> DeleteAsync(ConflictProperties conflict, PartitionKey partitionKey, CancellationToken cancellationToken = default)
Parameters
conflict
ConflictPropertiesThe conflict to delete.
partitionKey
PartitionKeyThe partition key for the conflict.
cancellationToken
CancellationToken(Optional) CancellationToken representing request cancellation.
Returns
- Task<ResponseMessage>
A Task representing the asynchronous operation.
- See Also
GetConflictQueryIterator<T>(QueryDefinition, string, QueryRequestOptions)
Obtains an iterator to go through the ConflictProperties on an Azure Cosmos container.
public abstract FeedIterator<T> GetConflictQueryIterator<T>(QueryDefinition queryDefinition, string continuationToken = null, QueryRequestOptions requestOptions = null)
Parameters
queryDefinition
QueryDefinitionThe cosmos SQL query definition.
continuationToken
string(Optional) The continuation token in the Azure Cosmos DB service.
requestOptions
QueryRequestOptions(Optional) The options for the item query request QueryRequestOptions
Returns
- FeedIterator<T>
An iterator to go through the conflicts.
Type Parameters
T
Examples
using (FeedIterator<ConflictProperties> feedIterator = conflicts.GetConflictQueryIterator())
{
while (feedIterator.HasMoreResults)
{
FeedResponse<ConflictProperties> response = await feedIterator.ReadNextAsync();
foreach (var conflict in response)
{
Console.WriteLine(conflict);
}
}
}
GetConflictQueryIterator<T>(string, string, QueryRequestOptions)
Obtains an iterator to go through the ConflictProperties on an Azure Cosmos container.
public abstract FeedIterator<T> GetConflictQueryIterator<T>(string queryText = null, string continuationToken = null, QueryRequestOptions requestOptions = null)
Parameters
queryText
stringThe cosmos SQL query text.
continuationToken
string(Optional) The continuation token in the Azure Cosmos DB service.
requestOptions
QueryRequestOptions(Optional) The options for the item query request.
Returns
- FeedIterator<T>
An iterator to go through the conflicts.
Type Parameters
T
Examples
using (FeedIterator<ConflictProperties> conflictIterator = conflicts.GetConflictQueryIterator())
{
while (feedIterator.HasMoreResults)
{
FeedResponse<ConflictProperties> response = await feedIterator.ReadNextAsync();
foreach (var conflict in response)
{
Console.WriteLine(conflict);
}
}
}
GetConflictQueryStreamIterator(QueryDefinition, string, QueryRequestOptions)
Gets an iterator to go through all the conflicts for the container as the original ResponseMessage
public abstract FeedIterator GetConflictQueryStreamIterator(QueryDefinition queryDefinition, string continuationToken = null, QueryRequestOptions requestOptions = null)
Parameters
queryDefinition
QueryDefinitionThe cosmos SQL query definition.
continuationToken
string(Optional) The continuation token in the Azure Cosmos DB service.
requestOptions
QueryRequestOptions(Optional) The options for the item query request.
Returns
- FeedIterator
An iterator to go through the conflicts.
Examples
Example on how to fully drain the query results.
QueryDefinition queryDefinition = new QueryDefinition("select * From c where c._rid = @rid")
.WithParameter("@rid", "TheRidValue");
using (FeedIterator feedIterator = this.CosmosClient.GetConflictQueryStreamIterator(
queryDefinition))
{
while (feedIterator.HasMoreResults)
{
// Stream iterator returns a response with status for errors
using(ResponseMessage response = await feedIterator.ReadNextAsync())
{
// Handle failure scenario.
if(!response.IsSuccessStatusCode)
{
// Log the response.Diagnostics and handle the error
}
}
}
}
GetConflictQueryStreamIterator(string, string, QueryRequestOptions)
Gets an iterator to go through all the conflicts for the container as the original ResponseMessage
public abstract FeedIterator GetConflictQueryStreamIterator(string queryText = null, string continuationToken = null, QueryRequestOptions requestOptions = null)
Parameters
queryText
stringThe cosmos SQL query text.
continuationToken
string(Optional) The continuation token in the Azure Cosmos DB service.
requestOptions
QueryRequestOptions(Optional) The options for the item query request.
Returns
- FeedIterator
An iterator to go through the conflicts.
Examples
Example on how to fully drain the query results.
using (FeedIterator feedIterator = this.CosmosClient.GetConflictQueryStreamIterator(
"select * From c where c._rid = \"TheRidValue\""))
{
while (feedIterator.HasMoreResults)
{
// Stream iterator returns a response with status for errors
using(ResponseMessage response = await feedIterator.ReadNextAsync())
{
// Handle failure scenario.
if(!response.IsSuccessStatusCode)
{
// Log the response.Diagnostics and handle the error
}
}
}
}
ReadConflictContent<T>(ConflictProperties)
Reads the content of the Conflict resource in the Azure Cosmos DB service.
public abstract T ReadConflictContent<T>(ConflictProperties conflict)
Parameters
conflict
ConflictPropertiesThe conflict for which we want to read the content of.
Returns
- T
The content of the conflict.
Type Parameters
T
Examples
using (FeedIterator<ConflictProperties> conflictIterator = conflicts.GetConflictQueryIterator())
{
while (conflictIterator.HasMoreResults)
{
foreach(ConflictProperties item in await conflictIterator.ReadNextAsync())
{
MyClass intendedChanges = conflicts.ReadConflictContent<MyClass>(item);
}
}
}
- See Also
ReadCurrentAsync<T>(ConflictProperties, PartitionKey, CancellationToken)
Reads the item that originated the conflict.
public abstract Task<ItemResponse<T>> ReadCurrentAsync<T>(ConflictProperties conflict, PartitionKey partitionKey, CancellationToken cancellationToken = default)
Parameters
conflict
ConflictPropertiesThe conflict for which we want to read the item.
partitionKey
PartitionKeyThe partition key for the item.
cancellationToken
CancellationToken(Optional) CancellationToken representing request cancellation.
Returns
- Task<ItemResponse<T>>
The current state of the item associated with the conflict.
Type Parameters
T
Examples
using (FeedIterator<ConflictProperties> conflictIterator = conflicts.GetConflictQueryIterator())
{
while (conflictIterator.HasMoreResults)
{
foreach(ConflictProperties item in await conflictIterator.ReadNextAsync())
{
MyClass intendedChanges = conflicts.ReadConflictContent<MyClass>(item);
ItemResponse<MyClass> currentState = await conflicts.ReadCurrentAsync<MyClass>(item, intendedChanges.MyPartitionKey);
}
}
}
- See Also