I am trying to create a paginated scan request, but I'm not sure how to begin.
I have my table and DTO for the table like so
[DynamoDBTable("ProfileMetrics")]
public class ProfileMetricsDTO
{
[DynamoDBHashKey]
public string ProfileId { get; set; }
[DynamoDBRangeKey]
public string Key { get; set; }
}
Now, I want to find all ProfileMetrics that have a key of, say, "My_Key". And since there will probably be lots of them I need to paginate the results. I read about the LastEvaluatedKey and the ExclusiveStartKey but I don't see how to provide these when I try to do a scan like so:
IEnumerable<ProfileMetricsDTO> results = context.Scan<ProfileMetricsDTO>(new ScanCondition("Key", ScanOperator.Equal, "My_Key"));
How do I limit the results and provide paging?
I just found, you can use something like
context.FromScan<T>(new ScanOperationConfig
{
Limit = 10,
Filter = ...
});
There are FromQuery
, FromQueryAsync
, FromScan
, FromScanAsync
in the context.
在更彻底地阅读文档之后,这似乎是不可能的。
Looks like you can do this by setting the ExclusiveStartKey in the ScanRequest:
// Create Scan request
ScanRequest request = new ScanRequest
{
TableName = "SampleTable",
ExclusiveStartKey = startKey,
ScanFilter = conditions
};
See the example here: http://aws-sdk-v2-preview-docs.s3-website-us-east-1.amazonaws.com/items/T_Amazon_DynamoDBv2_Model_ScanRequest_NET3_5.html
There is very good documentation on exactly how to do this. The documentation includes lots of example code.
I got my application up and running very easily by following this documentation.
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelDotNetScanning.html
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.