.Net Core - DynamoDB ScanAsync 方法不返回特定记录的数据

问题描述 投票:0回答:1

我在尝试访问 .Net core 6 API 中的数据时遇到了 AWS DynamoDB 的烦人问题。这是检索数据的代码部分,作者:

user_id

private readonly AmazonDynamoDBClient _amazonDynamoDB; // assigned by dependency injection through constructor) 
string tableName = _serviceConfiguration.AWS.DynamoDB.TableName;
var result = await _amazonDynamoDB.ScanAsync(new ScanRequest
{
    TableName = tableName,
    ExpressionAttributeValues = new Dictionary<string, AttributeValue>
    {
        {":user_id", new AttributeValue {S = userId_input}},
    },
    FilterExpression = "user_id = :user_id"
});

奇怪的是,对于某些特定的

userId_input
,我得到0个数据(
result.Count
为0),而另一个API可以将新项目添加到DynamoDB数据库中,或者我可以从AWS界面扫描这些记录。它仅发生在某些
user_id
值上。

我想这可能没有包含足够的信息,但由于这是一个商业项目,我需要尽可能多地涵盖。但是,如果故障排除过程确实需要任何东西,我会尽力提供。 对于这个问题,您知道可能是什么原因吗?

amazon-web-services .net-core amazon-dynamodb
1个回答
1
投票

结果被分页。您需要不断拉动页面。具体请参阅 https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelDotNetScanning.html

ExclusiveStartKey

© www.soinside.com 2019 - 2024. All rights reserved.