azure table storage pagination for request 10 items each time

前端 未结 1 361
小鲜肉
小鲜肉 2021-01-28 08:56

Basically I am trying to get pagination working when requesting entities of azure table storage. i.e. Press next button gets the next 10 entities & Press previous button get

1条回答
  •  遇见更好的自我
    2021-01-28 09:18

    Managed to solved the problem under Gaurav's help. Here is the code, not perfect but works.

    private async Task> queryPage(CloudTable peopleTable, string item, string NextPartitionKey , string NextRowKey, int itemNumber)
        {
            // Construct the query operation for all customer entities 
            TableQuery query = new TableQuery().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, item)).Take(itemNumber);
    
    
            // Print the fields for each customer.
            List data = new List();
    
            Tabletoken.NextPartitionKey = NextPartitionKey;
            Tabletoken.NextRowKey = NextRowKey;
            TableQuerySegment resultSegment = await peopleTable.ExecuteQuerySegmentedAsync(query, Tabletoken);
            Tabletoken = resultSegment.ContinuationToken;
    
    
            foreach (CustomerEntity entity in resultSegment.Results)
            {
    
                data.Add(new UserInfo
                {
                    //add data
                });
    
            }
    
            return data;
        }
    
        private TableContinuationToken Tabletoken = new TableContinuationToken();
    

    and declare it use a tuple.

     Tuple, string, string > tuple =
                    new Tuple, string, string>(data, Tabletoken.NextPartitionKey, Tabletoken.NextRowKey);
    

    0 讨论(0)
提交回复
热议问题