[英]Paginated DynamoDB Scan/Query .Net
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 我有这样的桌子和桌子的DTO
[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". 现在,我想找到所有键为“ My_Key”的ProfileMetrics。 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:
我阅读了有关LastEvaluatedKey和ExclusiveStartKey的信息,但是在尝试进行如下扫描时,我看不到如何提供这些信息:
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. 上下文中有
FromQuery
, FromQueryAsync
, FromScan
, FromScanAsync
。
在更彻底地阅读文档之后,这似乎是不可能的。
Looks like you can do this by setting the ExclusiveStartKey in the ScanRequest: 看起来您可以通过在ScanRequest中设置ExclusiveStartKey来做到这一点:
// 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 请参阅此处的示例: 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 http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelDotNetScanning.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.