简体   繁体   中英

How can I achieve DynamoDB Pagination Same as SQL/MYSQL(Total count of items and I can jump to any other page) in C#

how to implement pagination using DynamoDB in c# same as SQL/MYSQL.

I have check document for ScanRequest and QueryRequest that one is working perfectly fine.

But I need Pagination same as we all do in SQL/MYSQL like in initial call I need total number of item count and page wise records and easily I can jump to any other page also.

So anyone can suggest good solution or any alternative solution?

Thank you in advance.

Dictionary<string, AttributeValue> lastKeyEvaluated = null;
            do
            {
                var request = new ScanRequest
                {
                    TableName = "Test",
                    Limit = 5,
                    ExclusiveStartKey = lastKeyEvaluated
                };
                var response = await Client.ScanAsync(request);
                lastKeyEvaluated = response.LastEvaluatedKey;

            }
            while (lastKeyEvaluated.Count != 0);




            Dictionary<string, Condition> conditions = new Dictionary<string, Condition>();
            // Title attribute should contain the string "Adventures"
            Condition titleCondition = new Condition();
            titleCondition.ComparisonOperator = ComparisonOperator.EQ;
            titleCondition.AttributeValueList.Add(new AttributeValue { S = "Company#04" });
            conditions["PK"] = titleCondition;


            var request = new QueryRequest();
            request.Limit = 2;
            request.ExclusiveStartKey = null;
            request.TableName = "Test";
            request.KeyConditions = conditions;

            var result = await Client.QueryAsync(request);

DynamoDB supports an entirely different type of pagination . The concept of page number, offset, etc. is another paradigm from the SQL database world that has no parallel in DynamoDB. However, pagination is supported, just not the way many expect.

You may want to consider changing how your client application paginates to accommodate. If you have a small amount of information to paginate (eg under 1MB of data), you might consider passing it to the client and letting the client implement the pagination (eg page 4 of 15).

If you have too much data to paginate client-side, you may want to consider updating your client application to accommodate how DynamoDB paginates (eg using LastEvaluatedKey and ExclusiveStartKey ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM