/// <summary> /// Delete an entity based on it's keys. If the entity does not exist then no exception will be thrown. /// </summary> /// <param name="partitionKey">Entity to delete partition key.</param> /// <param name="rowKey">Entity to delete row key.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The task object representing the asynchronous operation.</returns> public async Task DeleteIfExistsAsync(string partitionKey, string rowKey, CancellationToken cancellationToken = default) { var entity = await GetByKeysAsync(partitionKey, rowKey, cancellationToken); if (entity == null) { return; } await FuncUtils.SwallowNotFoundAsync(e => _table.DeleteAsync(e, cancellationToken), entity); }
/// <summary> /// Delete an entity. If the entity does not exist then no exception will be thrown. /// </summary> /// <param name="entity">Entity to delete.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The task object representing the asynchronous operation.</returns> /// <exception cref="T:System.ArgumentNullException"><paramref name="entity" /> is null.</exception> public Task DeleteIfExistsAsync(TEntity entity, CancellationToken cancellationToken = default) { return(FuncUtils.SwallowNotFoundAsync(e => _table.DeleteAsync(e, cancellationToken), entity)); }
/// <summary> /// Replace an existing entity. If the entity does not exist no exception is thrown. /// </summary> /// <param name="entity">Entity to replace.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The task object representing the asynchronous operation.</returns> /// <exception cref="T:System.ArgumentNullException"><paramref name="entity" /> is null.</exception> public Task ReplaceIfExistsAsync(TEntity entity, CancellationToken cancellationToken = default) { return(FuncUtils.SwallowNotFoundAsync(e => ReplaceAsync(e, cancellationToken), entity)); }