Now, we are going to see how to query items from the table using the object persistence model in .Net
To perform this recipe, you should have set up the project, as described in the earlier recipes, specifically pom.xml
and setting up dependencies and the object model.
Let's see how to query items from the table using the object persistence model in .Net:
Create an instance of
AmazonDynamoDBClient
and instantiate theDynamoDBContext
class, which will be the entry point to DynamoDB:AmazonDynamoDBClient client = new AmazonDynamoDBClient(); DynamoDBContext context = new DynamoDBContext(client);
Now, let's write a query that will fetch the items whose ID is 111 and type starts with
b
:IEnumerable<Product> products = context.Query<Product>(111, QueryOperator.BeginsWith, "b");
Now, we can iterate over the products' list to go through the results.