Search code examples
c#asp.netazureazure-table-storageazure-tablequery

How to Filter the query result for pagination in TableClient.QueryAsync() [Azure.Data.Tables]


I am using the Azure.Data.Tables package & TableClient.QueryAsync() method to get the query result. I wants the result to use it for pagination. I came across this code in https://learn.microsoft.com/en-us/dotnet/api/azure.data.tables.tableclient.queryasync?view=azure-dotnet

Pageable<T> pageable = client.QueryAsync<T>(filter : value, maxPerPage : 10);

What are the changes should I make ?

Thanks in Advance !! :)


Solution

  • Here is a snippet from our samples.

    AsyncPageable<TableEntity> queryResultsMaxPerPage = tableClient.QueryAsync<TableEntity>(filter: $"PartitionKey eq '{partitionKey}'", maxPerPage: 10);
        
                    await foreach (Page<TableEntity> page in queryResultsMaxPerPage.AsPages())
                    {
                        Console.WriteLine("This is a new page!");
                        foreach (TableEntity qEntity in page.Values)
                        {
                            Console.WriteLine($"# of {qEntity.GetString("Product")} inventoried: {qEntity.GetInt32("Quantity")}");
                        }
                    }