Search documentationEsc

IWriteOnlyRepository<TItem>

This is the write-only repository interface for any implementation of

Namespace: Microsoft.Azure.CosmosRepository
Kind: interface

This is the write-only repository interface for any implementation of TItem, exposing asynchronous create, update, and delete functionality.

public interface IWriteOnlyRepository<TItem> where TItem : IItem

Type parameters

NameDescription
TItemThe IItem implementation class type.

Example

With DI, use .ctor injection to require any implementation of IItem:

public class ConsumingService
{
readonly IWriteOnlyRepository<SomePoco> _pocoRepository;
public ConsumingService(
IWriteOnlyRepository<SomePoco> pocoRepository) =>
_pocoRepository = pocoRepository;
}

Members

Methods

IWriteOnlyRepository<TItem>.CreateAsync(TItem, CancellationToken)

Creates a cosmos item representing the given value.

ValueTask<TItem> CreateAsync(TItem value, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
value{TItem}The item value to create.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsValueTask{{TItem}}: A ValueTask representing the IItem implementation class instance as a TItem.

IWriteOnlyRepository<TItem>.CreateAsync(IEnumerable<TItem>, CancellationToken)

Creates one or more cosmos item(s) representing the given values.

ValueTask<IEnumerable<TItem>> CreateAsync(IEnumerable<TItem> values, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
valuesIEnumerable{{TItem}}The item values to create.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsIEnumerable{{TItem}}}: A collection of created item instances.

IWriteOnlyRepository<TItem>.UpdateAsync(TItem, bool, CancellationToken)

Updates the cosmos object that corresponds to the given value.

ValueTask<TItem> UpdateAsync(TItem value, bool ignoreEtag = false, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
value{TItem}The item value to update.
ignoreEtagBooleanWhen TItem implements IItemWithEtag the etag will be verified on all updates. Setting this flag to true indicates that the etag should be ignored.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsValueTask{{TItem}}: A ValueTask representing the IItem implementation class instance as a TItem.

IWriteOnlyRepository<TItem>.UpdateAsync(IEnumerable<TItem>, bool, CancellationToken)

Updates one or more cosmos item(s) representing the given values.

ValueTask<IEnumerable<TItem>> UpdateAsync(IEnumerable<TItem> values, bool ignoreEtag = false, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
valuesIEnumerable{{TItem}}The item values to update.
ignoreEtagBooleanWhen TItem implements IItemWithEtag the etag will be verified on all updates. Setting this flag to true indicates that the etag should be ignored.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsIEnumerable{{TItem}}}: A collection of updated item instances.

IWriteOnlyRepository<TItem>.UpdateAsync(string, Action<IPatchOperationBuilder<TItem>>, string?, string?, CancellationToken)

Updates the given cosmos item using the provided and supported patch operations.

ValueTask UpdateAsync(string id, Action<IPatchOperationBuilder<TItem>> builder, string? partitionKeyValue = null, string? etag = null, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
idStringThe string identifier.
builderIPatchOperationBuilder{{TItem}}}The IPatchOperationBuilder that will define the update operations to perform.
partitionKeyValueStringThe partition key value if different than the Id.
etagStringIndicate to set IfMatchEtag in the ItemRequestOptions in the underlying Cosmos call. This requires TItem to implement the IItemWithEtag interface.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsValueTask: A ValueTask representing the asynchronous operation.

IWriteOnlyRepository<TItem>.DeleteAsync(TItem, CancellationToken)

Deletes the cosmos object that corresponds to the given value.

ValueTask DeleteAsync(TItem value, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
value{TItem}The object to delete.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsValueTask: A ValueTask representing the asynchronous delete operation.

IWriteOnlyRepository<TItem>.DeleteAsync(string, string?, CancellationToken)

Deletes the cosmos object that corresponds to the given id.

ValueTask DeleteAsync(string id, string? partitionKeyValue = null, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
idStringThe string identifier.
partitionKeyValueStringThe partition key value if different than the Id.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsValueTask: A ValueTask representing the asynchronous delete operation.

IWriteOnlyRepository<TItem>.DeleteAsync(string, PartitionKey, CancellationToken)

Deletes the cosmos object that corresponds to the given id.

ValueTask DeleteAsync(string id, PartitionKey partitionKey, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
idStringThe string identifier.
partitionKeyPartitionKeyThe PartitionKey value if different than the Id.
cancellationTokenCancellationTokenThe cancellation token to use when making asynchronous operations.

ReturnsValueTask: A ValueTask representing the asynchronous delete operation.