Last active
May 16, 2022 15:33
-
-
Save vitormeriat/a0f76e4fb7de5c689130628941ff5845 to your computer and use it in GitHub Desktop.
Check if an entity exists in a Azure Table Storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks easier