User guide
// using Amazon.DynamoDBv2.Model;
// Provides a sample item that can be added to a table.
public static Dictionary<string, AttributeValue> CreateItemData()
{
var itemData = new Dictionary<string, AttributeValue>
{
{ "Id", new AttributeValue { N = "301" } },
{ "Title", new AttributeValue { S = "18\" Girl's Bike" } },
{ "BicycleType", new AttributeValue { S = "Road" } },
{ "Brand" , new AttributeValue { S = "Brand-Company C" } },
{ "Color", new AttributeValue { SS = new List<string>{ "Blue", "Silver" }
} },
{ "Description", new AttributeValue { S = "301 description" } },
{ "Gender", new AttributeValue { S = "F" } },
{ "InStock", new AttributeValue { BOOL = true } },
{ "Pictures", new AttributeValue { L = new List<AttributeValue>{
{ new AttributeValue { M = new Dictionary<string,AttributeValue>{
{ "FrontView", new AttributeValue { S = "http://ex
ample/products/301_front.jpg" } } } } },
{ new AttributeValue { M = new Dictionary<string,AttributeValue>{
{ "RearView", new AttributeValue {S = "http://ex
ample/products/301_rear.jpg" } } } } },
{ new AttributeValue { M = new Dictionary<string,AttributeValue>{
{ "SideView", new AttributeValue { S = "http://ex
ample/products/301_left_side.jpg" } } } } }
} } },
{ "Price", new AttributeValue { N = "185" } },
{ "ProductCategory", new AttributeValue { S = "Bike" } },
{ "ProductReviews", new AttributeValue { M = new Dictionary<string,Attrib
uteValue>{
{ "FiveStar", new AttributeValue { SS = new List<string>{
"My daughter really enjoyed this bike!" } } },
{ "OneStar", new AttributeValue { SS = new List<string>{
"Fun to ride.",
"This bike was okay, but I would have preferred it in my color." } } }
} } },
{ "QuantityOnHand", new AttributeValue { N = "3" } },
{ "RelatedItems", new AttributeValue { NS = new List<string>{ "979", "822",
"801" } } }
};
return itemData;
}
In the preceding example, an example item with sample data is returned to the caller. A series of attributes
and corresponding values are constructed, using data types such as BOOL, L, M, N, NS, S, and SS, which
correspond to those in the JSON Data Format.
Update an Item by Using Expressions
The following example features the Amazon.DynamoDBv2.AmazonDynamoDBClient.UpdateItem
method and a set of expressions to change the Title to 18" Girl's Bike for the item with Id of 301.
Version v2.0.0
61
AWS SDK for .NET Developer Guide
Using Expressions with DynamoDB