Differnt Conditional Operator for DynamoDb ScanCondition in .NET

328 views Asked by At

How to use different conditional operator in one dynamoDb scan to connect many scan conditiion. For example: I need to get all entities where Age > 18 && BirthPlace == "Great Britain" || Birthplace == "USA"?

1

There are 1 answers

0
Seth Geoghegan On BEST ANSWER

Accordig to the scan docs for logical evaluation, you can use OR and AND operations with parenthesis. For example:

{
    "TableName": "<YOUR TABLE>",
    "FilterExpression": "#age = :age AND (#birthplace = :gb OR #birthplace = :usa)",
    "ExpressionAttributeNames": {"#birthplace":"BirthPlace","#age":"Age"},
    "ExpressionAttributeValues": {":gb": {"S":"Great Birttain"},":usa": {"S":"USA"},":age": {"N":"Age"}}
}