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 : IItemType parameters
| Name | Description |
|---|---|
TItem | The 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
| Name | Type | Description |
|---|---|---|
value | {TItem} | The item value to create. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — ValueTask{{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
| Name | Type | Description |
|---|---|---|
values | IEnumerable{{TItem}} | The item values to create. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — IEnumerable{{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
| Name | Type | Description |
|---|---|---|
value | {TItem} | The item value to update. |
ignoreEtag | Boolean | When TItem implements IItemWithEtag the etag will be verified on all updates. Setting this flag to true indicates that the etag should be ignored. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — ValueTask{{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
| Name | Type | Description |
|---|---|---|
values | IEnumerable{{TItem}} | The item values to update. |
ignoreEtag | Boolean | When TItem implements IItemWithEtag the etag will be verified on all updates. Setting this flag to true indicates that the etag should be ignored. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — IEnumerable{{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
| Name | Type | Description |
|---|---|---|
id | String | The string identifier. |
builder | IPatchOperationBuilder{{TItem}}} | The IPatchOperationBuilder that will define the update operations to perform. |
partitionKeyValue | String | The partition key value if different than the Id. |
etag | String | Indicate to set IfMatchEtag in the ItemRequestOptions in the underlying Cosmos call. This requires TItem to implement the IItemWithEtag interface. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — ValueTask: 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
| Name | Type | Description |
|---|---|---|
value | {TItem} | The object to delete. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — ValueTask: 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
| Name | Type | Description |
|---|---|---|
id | String | The string identifier. |
partitionKeyValue | String | The partition key value if different than the Id. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — ValueTask: 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
| Name | Type | Description |
|---|---|---|
id | String | The string identifier. |
partitionKey | PartitionKey | The PartitionKey value if different than the Id. |
cancellationToken | CancellationToken | The cancellation token to use when making asynchronous operations. |
Returns — ValueTask: A ValueTask representing the asynchronous delete operation.