Question

I'm using the .NET SDK of DynamoDB to scan records by applying a BETWEEN filter condition. But I don't get any results - the Count prints as 0 (but the results are available in DB which I verified through AWS console). Any idea what could be wrong in this code?

        AmazonDynamoDBClient client = new AmazonDynamoDBClient();

        AttributeValue av1 = new AttributeValue();
        av1.N = "373543227";
        AttributeValue av2 = new AttributeValue();
        av2.N = "373543247";

        Condition c = new Condition();
        c.ComparisonOperator = ComparisonOperator.BETWEEN;
        c.AttributeValueList.Add(av1);
        c.AttributeValueList.Add(av2);

        ScanRequest sr = new ScanRequest();
        sr.TableName = "history";
        sr.ScanFilter.Add("MyNumericField", c);

        ScanResponse srp = client.Scan(sr);

        Console.WriteLine("Count {0}", srp.Count);

Documentation doesn't help for DynamoDB2! :(

Was it helpful?

Solution

How silly of me! It was only a partial scan till 1 MB result, after which I had to continue with sr.ExclusiveStartKey = srp.LastEvaluatedKey. That worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top