[英]How limit scan results in DynamoDB .NET
i have a question. 我有个问题。 I want to limit the result of scan over dynamodb. 我想限制通过dynamodb扫描的结果。 I read in documentation that "Limit" parameter on ScanRequest do this works, but this code it seems not working. 我在文档中读到了ScanRequest上的“ Limit”参数可以正常工作,但是此代码似乎不起作用。
I have 14 records, and this scan returns exactly 14 records, but should return 10. What i am doing wrong? 我有14条记录,并且此扫描恰好返回了14条记录,但应该返回10条。我在做什么错?
public IList<Contact> GetContacs(string firstContactToScan)
{
using (var context = new DynamoDBContext(new AmazonDynamoDBClient()))
{
var data = context.FromScan<Contact>(new ScanOperationConfig {Limit = 10}).ToList();
return data;
}
}
Thanks 谢谢
You can try following code: 您可以尝试以下代码:
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
var request = new ScanRequest
{
TableName = "yourTableName",
Limit = 10
};
var response = client.Scan(request);
var result = response.ScanResult;
foreach (Dictionary<string, AttributeValue> item in response.ScanResult.Items)
{
PrintItem(item);
}
There are other options also which you can specify in the request following is the Reference Link . 您还可以在请求中指定其他选项,以下是“ 引用链接” 。
Hope that helps 希望能有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.