Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Córdoba Cárdenas DaniCCardenas

View GitHub Profile
@vitormeriat
vitormeriat / entity_exists.cs
Last active May 16, 2022
Check if an entity exists in a Azure Table Storage
View entity_exists.cs
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();