User guide

else if (value.SS.Count > 0)
{
Console.Write("{0}", string.Join("\n", value.SS.ToArray()));
}
// Otherwise, boolean value.
else
{
Console.Write(value.BOOL);
}
Console.Write("\n");
}
In the preceding example, each attribute value has several data-type-specific properties that can be
evaluated to determine the correct format to print the attribute. These properties include properties such
as B, BOOL, BS, L, M, N, NS, NULL, S, and SS, which correspond to those in the JSON Data Format. For
properties such as B, N, NULL, and S, if the corresponding property is not null, then the attribute is of
the corresponding non-null data type. For properties such as BS, L, M, NS, and SS, if Count is greater
than zero, then the attribute is of the corresponding non-zero-value data type. If all of the attribute's
data-type-specific properties are either null or the Count equals zero, then the attribute corresponds
to the BOOL data type.
Create or Replace an Item by Using Expressions
The following example features the Amazon.DynamoDBv2.AmazonDynamoDBClient.PutItem method
and a set of expressions to update the item that has a Title of 18-Bicycle 301. If the item doesn't
already exist, a new item is added.
// using Amazon.DynamoDBv2;
// using Amazon.DynamoDBv2.Model;
var client = new AmazonDynamoDBClient();
var request = new PutItemRequest
{
TableName = "ProductCatalog",
ExpressionAttributeNames = new Dictionary<string, string>
{
{ "#title", "Title" }
},
ExpressionAttributeValues = new Dictionary<string, AttributeValue>
{
{ ":product", new AttributeValue { S = "18-Bicycle 301" } }
},
ConditionExpression = "#title = :product",
// CreateItemData() is a custom function.
Item = CreateItemData()
};
client.PutItem(request);
In the preceding example, the ExpressionAttributeNames property specifies the placeholder #title
to represent the Title attribute.The ExpressionAttributeValues property specifies the placeholder
:product to represent the value 18-Bicycle 301.The ConditionExpression property specifies
that #title (Title) must be equal to :product (18-Bicycle 301). The call to CreateItemData
refers to the following custom function:
Version v2.0.0
60
AWS SDK for .NET Developer Guide
Using Expressions with DynamoDB