Azure Table Query async - continuation token was always returned

I'm trying to do asynchronous TableQuery

using Azure Table Storage with ExecuteQuerySegmentedAsync

. Below is the relevant part of the code:

public async Task<List<MyEntity>> GetTableData()
{
    CloudTableClient tableClient = GetTableClient();

    CloudTable table = tableClient.GetTableReference("MyTableName");

    TableQuery<MyEntity> query = new TableQuery<MyEntity>().Take(10);

    List<MyEntity> results = new List<MyEntity>();
    TableContinuationToken token = null;

    do
    {
        var seg = await table.ExecuteQuerySegmentedAsync(query, token);
        token = seg.ContinuationToken;
        results.AddRange(seg.Results);
    }
    while (token != null);

    return results
}

      

The problem is that as long as it ExecuteQuerySegmentedAsync

returns the correct number of records, the continuation token is never null and the loop is constant.

Can anyone point me in the right direction?

I am using Windows Azure Storage 4.3.0.0

+3


source to share


1 answer


This is expected behavior. Basically you are retrieving all entities from your table with 10 entities at a time ( new TableQuery<MyEntity>().Take(10)

). So in one call, the table service returns 10 entities to you and because there are more than 10 entities in the table (I assume) it returns a continuation token and hence the loop continues.



+1


source







All Articles