I have an AWS DynamoDB Table with the following structure:
I am trying to get back all the items that have at least one RequestItem with the Id 3401. Here is what I've tried so far (c# code):
IAmazonDynamoDB client = new AmazonDynamoDBClient(
new BasicAWSCredentials(configuration["AccessKey"], configuration["SecretKey"]),
RegionEndpoint.USEast1);
var request = new ScanRequest
{
TableName = "dynamo-table-name",
ExpressionAttributeNames = new Dictionary<string, string>
{
{"#requestItems", "RequestItems"},
{"#requestId", "Id"}
},
ExpressionAttributeValues = new Dictionary<string, AttributeValue>
{
{":val", new AttributeValue {N = "3401"}}
},
FilterExpression = "contains(#requestItems.#requestId, :val)"
};
var response = await client.ScanAsync(request);
I did some variations on FilterExpression (using a simple "=" instead of "contains") but... I still don't get back the results. The query passes without errors, but the result it's an empty list.
However, the same code works for properties which are not collections (e.g. Contact.EmailAddress)
What am I missing?
[EDIT]
I tried another solution that was suggested:
var request = new ScanRequest
{
TableName = "dynamo-table-name",
ExpressionAttributeNames = new Dictionary<string, string>
{
{"#requestItems", "RequestItems"}
},
ExpressionAttributeValues = new Dictionary<string, AttributeValue>
{
{
":val",
new AttributeValue
{
L = new List<AttributeValue>
{
{
new AttributeValue
{
M = new Dictionary<string, AttributeValue>
{{"Id", new AttributeValue {N = "3401"}}}
}
}
}
}
}
},
FilterExpression = "contains(#requestItems, :val)"
};
var response = await client.ScanAsync(request);
but I still do not receive results.