0

I am using the Azure.Data.Tables.TableClient to query data from my database.

// Create table client
var tableServiceClient = new TableServiceClient(connectionString, _tableClientOptions);
avr tableClient = tableServiceClient.GetTableClient(tableName);

// Query data
var entities = _tableClient.QueryAsync<T>(e => e.PartitionKey == partitionKey, null, null, cT);

var resultList = new List<T>();

There seems to be two ways to enumerate the results. And from the looks of it .AsPages way could be making much fewer n/w calls to get the same data. Should I be using it all the time with a page size of, say 10?

1. Per item

var enumerator = asyncPageable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
    resultList.Add(enumerator.Current);
}

2. As Pages

var continuationToken = "";
var enumerator = asyncPageable.AsPages(continuationToken, 10).GetAsyncEnumerator();
var resultList = new List<T>();
while (await enumerator.MoveNextAsync())
{
    resultList.AddRange(enumerator.Current.Values);
}
Nikhil Girraj
  • 1,135
  • 1
  • 15
  • 33

0 Answers0