Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit doesn't work when query with context.fromquery in dynamodb

using c#, the code is like this

        DynamoDBContext context = new DynamoDBContext(client, new DynamoDBContextConfig() { TableNamePrefix = "lalala" });

        QueryFilter filter = new QueryFilter();
        filter.AddCondition("Userid", QueryOperator.Equal, "hashkeyvalue");
        QueryOperationConfig queryConfig = new QueryOperationConfig
        {
            Filter = filter,
            Select = SelectValues.AllProjectedAttributes,
            Limit = 1,
            IndexName = "Userid-UpdatedAtTimestamp-index"
        };
        try
        {
            var result = await context.FromQueryAsync<IAPRecord>(queryConfig).GetRemainingAsync();
            int ccc = result.Count;
        }
        catch (Exception ex)
        {
            throw new ArgumentException(ex.Message + ex.InnerException);
        }

and ccc should be 1 but now it equal to the whole set as if the Limit=1 doesn't exist.

Need helps!!

like image 391
shawhu Avatar asked Sep 27 '17 10:09

shawhu


1 Answers

resolved.

var query = context.FromQueryAsync<IAPRecord>(queryConfig);
var result = await query.GetNextSetAsync();
int ccc = result.Count;

Apparently GetRemainingAsync will get all the results regardless of how many you set to the limit parameter in the query. Instead, we should have use GetNextSetAsync.

like image 148
shawhu Avatar answered Nov 10 '22 13:11

shawhu