I'm using DynamoDB to query a table with the following commands
QueryRequest request = new QueryRequest
{
TableName = "Events",
ExclusiveStartKey = startKey,
KeyConditions = keyConditions,
IndexName = "Title-index" // Specify the index to query against
};
// Issue request
QueryResponse result = client.Query(request);
The ExclusiveStartKey and Keyconditions are predefined
The issue is that the QueryResult result variable is not parsed to my native object, when I use the DynamoDB.Context you cast the method with the expected type, but in this case I need to parse the QueryResult... Is there any other way to do this? Or should I parse the object?
I ended up using something like:
using System.Linq;
...
// Issue request
QueryResponse result = AmazonDynamoDBClient.Query(request);
var items = result.Items.FirstOrDefault();
var doc = Document.FromAttributeMap(items);
var myModel = DynamoDBContext.FromDocument<MyModelType>(doc);
What you want is some sort of ORM - a nice read is Using Amazon DynamoDB Object Persistence Framework. Also check out the API reference that also shows samples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With