Skip to content

Instantly share code, notes, and snippets.

View DaniCCardenas's full-sized avatar

Daniel Córdoba Cárdenas DaniCCardenas

View GitHub Profile
@vitormeriat
vitormeriat / entity_exists.cs
Last active May 16, 2022 15:33
Check if an entity exists in a Azure Table Storage
public async Task<bool> EntityExists(string partitionKey, string rowKey)
{
var tableQuery = new TableQuery<DynamicTableEntity>();
tableQuery.FilterString = TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey),
TableOperators.And,
TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, rowKey));
var dynamicTableEntities = await CloudTable.ExecuteQuerySegmentedAsync(tableQuery, null, TableRequestOptions, OperationContext);
return dynamicTableEntities.Results.Any();