DynamoDB Query Request Limit Not working?

0

Hey guys working on a project. I'm able to query my dynamoDB index but it seems the limit parameters in my request isn't working. Any help?
var request = new QueryRequest
{
TableName = "exampleTable",
IndexName = "exampleIndex",
Limit = 3,
ExclusiveStartKey = lastKeyEvaluated,
ExpressionAttributeValues = new Dictionary<string, AttributeValue> {
{ ":val", new AttributeValue { S = "Yes" } },
{ ":v_1", new AttributeValue { N = "0" }}
},
KeyConditionExpression = "Active= :val and Amount > :v_1",
ProjectionExpression = "Active, Amount",
ScanIndexForward = false
};

  I have 6 items on my table. (Prototyping bigger project) One of which has a negative "Amount". So that one is filtered out. However I'm still returned with 5 responses. It seems something is wrong with my limit parameters. Any help?  

Thanks everyone.

asked 3 years ago692 views
1 Answer
0

Okay cool, so basically the issue was not with the structure of my request but the actual processing of my queryasync. Whereas I was printing the info before the final key was evaluated now I called my print method after the final key was evaluated.

Client.QueryAsync(request, (result) => {

        if (result.Exception == null)  
        {  
             //previous spot for the foreach loop and the print method.  
              
            lastKeyEvaluated = result.Response.LastEvaluatedKey;  
            if (lastKeyEvaluated != null && lastKeyEvaluated.Count != 0)  
            {  
                foreach (Dictionary<string, AttributeValue> item  
                in result.Response.Items)  
                {  
                    PrintItem(item);  
                }  
                Query(lastKeyEvaluated);  
            }  
            else  
            {  
                Debug.Log("last one");  
            }  
        }  
        else  
        {  
            Debug.Log(result.Exception);  
        }  

    });
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions