Class TableStorageClient<TElement>
Base class for all services implementing the ITableStorageClient interface.
Inheritance
Implements
Inherited Members
Namespace: Celerik.NetCore.Util
Assembly: cs.temp.dll.dll
Syntax
public abstract class TableStorageClient<TElement> : ITableStorageClient<TElement> where TElement : ITableEntity, new()
Type Parameters
Name | Description |
---|---|
TElement | The type of table entity. |
Constructors
TableStorageClient(TableStorageConfig)
Initializes a new instance of the class.
Declaration
public TableStorageClient(TableStorageConfig config)
Parameters
Type | Name | Description |
---|---|---|
TableStorageConfig | config | Configuration to access the Table Storage. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If config is null. |
PropNullOrEmptyException | If ConnectionString or TableName are null or empty. |
System.FormatException | If ConnectionString or TableName have an invalid format. |
System.ArgumentException | If TableName is a reserved table name. |
Properties
Config
Configuration to access the Table Storage.
Declaration
public TableStorageConfig Config { get; }
Property Value
Type | Description |
---|---|
TableStorageConfig |
Methods
AnyAsync(String, String)
Checks if an entity with the passed-in partitionKey and rowKey exists.
Declaration
public Task<bool> AnyAsync(string partitionKey, string rowKey)
Parameters
Type | Name | Description |
---|---|---|
System.String | partitionKey | Partitition Key. |
System.String | rowKey | Row Key. |
Returns
Type | Description |
---|---|
Task<System.Boolean> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If partitionKey or rowKey are null. |
TableStorageException | If there was an error performing the operation. |
CreateTableIfNotExistsAsync()
Creates the table if not exists.
Declaration
protected virtual Task CreateTableIfNotExistsAsync()
Returns
Type | Description |
---|---|
Task | The task object representing the asynchronous operation. |
DeleteAsync(TElement)
Deletes an existing entity.
Declaration
public Task<TElement> DeleteAsync(TElement entity)
Parameters
Type | Name | Description |
---|---|---|
TElement | entity | The entity to delete. |
Returns
Type | Description |
---|---|
Task<TElement> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If entity is null, or entity.PartitionKey is null or entity.RowKey is null. |
TableStorageException | If there was an error performing the operation. |
DeleteAsync(String, String)
Deletes an existing entity.
Declaration
public Task<TElement> DeleteAsync(string partitionKey, string rowKey)
Parameters
Type | Name | Description |
---|---|---|
System.String | partitionKey | Partitition Key. |
System.String | rowKey | Row Key. |
Returns
Type | Description |
---|---|
Task<TElement> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If partitionKey or rowKey are null. |
TableStorageException | If there was an error performing the operation. |
DeleteIfExistsAsync()
Delete the table if exists.
Declaration
public abstract Task<bool> DeleteIfExistsAsync()
Returns
Type | Description |
---|---|
Task<System.Boolean> | The task object representing the asynchronous operation. |
ExecuteAsync(TableOperation)
Executes the passed-in table operation.
Declaration
protected abstract Task<TableResult> ExecuteAsync(TableOperation operation)
Parameters
Type | Name | Description |
---|---|---|
TableOperation | operation | The operation to execute. |
Returns
Type | Description |
---|---|
Task<TableResult> | The task object representing the asynchronous operation. |
ExecuteAsync(TableQuery<TElement>, TableContinuationToken)
Executes the passed-in table query as a segment.
Declaration
protected abstract Task<TableQuerySegment<TElement>> ExecuteAsync(TableQuery<TElement> query, TableContinuationToken token)
Parameters
Type | Name | Description |
---|---|---|
TableQuery<TElement> | query | The tabe query. |
TableContinuationToken | token | The continuation token. |
Returns
Type | Description |
---|---|
Task<TableQuerySegment<TElement>> | The task object representing the asynchronous operation. |
GetAsync(String, String)
Gets an entity by its partitionKey and rowKey. If there is no entity with the passed-in criteria, null is returned.
Declaration
public Task<TElement> GetAsync(string partitionKey, string rowKey)
Parameters
Type | Name | Description |
---|---|---|
System.String | partitionKey | Partitition Key. |
System.String | rowKey | Row Key. |
Returns
Type | Description |
---|---|
Task<TElement> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If partitionKey or rowKey are null. |
TableStorageException | If there was an error performing the operation. |
InsertAsync(TElement)
Inserts a new entity.
Declaration
public Task<TElement> InsertAsync(TElement entity)
Parameters
Type | Name | Description |
---|---|---|
TElement | entity | The entity to insert. |
Returns
Type | Description |
---|---|
Task<TElement> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If entity is null. |
PropNullException | If PartitionKey or RowKey are null. |
TableStorageException | If there was an error performing the operation. |
ListAsync(String)
Gets a list of entities matching the given partitionKey. If Partition key is null, all entities will be returned (take into account that it could be a very expensive operation).
Declaration
public Task<List<TElement>> ListAsync(string partitionKey = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | partitionKey | Partition Key. |
Returns
Type | Description |
---|---|
Task<System.Collections.Generic.List<TElement>> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
TableStorageException | If there was an error performing the operation. |
UpdateAsync(TElement, TableStorageStrategy)
Updates an existing entity.
Declaration
public Task<TElement> UpdateAsync(TElement entity, TableStorageStrategy strategy = TableStorageStrategy.InsertOrReplace)
Parameters
Type | Name | Description |
---|---|---|
TElement | entity | The entity to update. |
TableStorageStrategy | strategy | Defines the strategy used to update the entity, by default it is set to: InsertOrReplace. |
Returns
Type | Description |
---|---|
Task<TElement> | The task object representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If entity is null. |
PropNullException | If PartitionKey or RowKey are null in the entity object. |
TableStorageException | If there was an error performing the operation. |