User guide
context.Save(item);
In the preceding example, the item is inserted through the DynamoDBContext class's Save method,
which takes an initialized instance of the .NET class that represents the item. (The instance of the
DynamoDBContext class is initialized with an instance of the AmazonDynamoDBClient class.)
The following example shows how to use an instance of this .NET object to get an item from a table in
DynamoDB:
// using Amazon.DynamoDBv2;
// using Amazon.DynamoDBv2.DataModel;
var client = new AmazonDynamoDBClient();
var context = new DynamoDBContext(client);
var item = context.Load<Item>(4, "Fish");
Console.WriteLine("Id = {0}", item.Id);
Console.WriteLine("Type = {0}", item.Type);
Console.WriteLine("Name = {0}", item.Name);
In the preceding example, the item is retrieved through the DynamoDBContext class's Load method,
which takes a partially-initialized instance of the .NET class that represents the hash-and-range primary
key of the item to be retrieved. (As before, the instance of the DynamoDBContext class is initialized with
an instance of the AmazonDynamoDBClient class.)
For more information and examples, see .NET: Object Persistence Model.
Additional Resources
For additional information and examples of programming DynamoDB with the SDK for .NET, see:
• DynamoDB APIs
• DynamoDB Series Kickoff
• DynamoDB Series - Document Model
• DynamoDB Series - Conversion Schemas
• DynamoDB Series - Object Persistence Model
• DynamoDB Series - Expressions
• Using Expressions with DynamoDB (p. 52)
• JSON Support in Amazon DynamoDB (p. 63)
• Managing ASP.NET Session State with Amazon DynamoDB (p. 65)
Amazon DynamoDB Programming with
Expressions by Using the AWS SDK for .NET
The following code examples demonstrate how to use the SDK for .NET to program DynamoDB with
expressions. Expressions denote the attributes that you want to read from an item in a DynamoDB table.
You also use expressions when writing an item, to indicate any conditions that must be met (also known
as a conditional update) and to indicate how the attributes are to be updated. Some update examples
are replacing the attribute with a new value, or adding new data to a list or a map. For more information
see Reading and Writing Items Using Expressions.
Version v2.0.0
52
AWS SDK for .NET Developer Guide
Additional Resources