0

i have a question. I want to limit the result of scan over dynamodb. I read in documentation that "Limit" parameter on ScanRequest do this works, but this code it seems not working.

I have 14 records, and this scan returns exactly 14 records, but should return 10. What i am doing wrong?

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I would like to do this using the high level client DynamoDbContext. It is not obvious if this is possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.