小编use*_*809的帖子

如何使用 DynamoDBContext 批处理结果

我正在使用 DynamoDB .NET 对象持久性模型来扫描具有以下条件的表。

public IEnumerable<Product> GetProducts(string attribute1Value, string attribute2Value
{
    IEnumerable<Product> products = null;
    try
    {
        RegionEndpoint region = RegionEndpoint.GetBySystemName("us-east-1");
        AmazonDynamoDB client = new AmazonDynamoDBClient(account.AwsAccessKey, account.AwsSecretKey, region);

        DynamoDBContext context = new DynamoDBContext(client);
        products = context.Scan<Product>(
            new ScanCondition("attribute1", ScanOperator.Equal, attribute1Value),
            new ScanCondition("attribute2", ScanOperator.Equal, attribute2Value));

    }
    catch (AmazonServiceException ase)
    {
        log.Error("Amazon Service Exception, Message: " + ase.Message + ", request id: " + ase.RequestId);
    }
    catch (Exception e)
    {
        log.Error("Exception: " + e.Message);
    }
    return products;
}
Run Code Online (Sandbox Code Playgroud)

当我使用 DynamoDBContext 时,当输出超过 DynamoDB …

.net amazon-web-services amazon-dynamodb

2
推荐指数
1
解决办法
1121
查看次数