How to retrieve a list of entities without specifying rowKey from Azure Table Storage in the TableOperation?

Viewed 511

As described here, is seems like there is no method for querying group of entities from azure table storage given only the partitionKey. https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.table.tableoperation.retrieve?view=azure-dotnet

I have several groups of partitionsKeys, with different rowKeys. But i want to query all entities just providing the partitionKey.enter image description here

How can this be done? Is there no way to do this using Microsoft.Azure.Cosmos.Table ? My rowKey values are not incremental/structured, but unique... Thanks

Update: Syntaks:

public async Task<T>> RetrieveEntitysAsync<T>(string paritionKey) where T : TableEntity, new()
{
    TableQuery<MyDataEntity> query = new TableQuery<MyDataEntity>()
        .Where(
            TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "myPartition")
            );


    await CloudTable.ExecuteQuery(query);

}
1 Answers

Retrieve operation is for retrieving a single entity from Table Storage. This is why you will need to specify both PartitionKey and RowKey.

If you want to retrieve multiple entities (e.g. entities matching a particular PartitionKey value), the method you would want to call is CloudTable.ExecuteQuery and provide a query (e.g. PartitionKey eq 'your-partition-key-value') to that method.

Related