User guide
// "HASH" = hash key, "RANGE" = range key.
KeyType = "HASH"
},
new KeySchemaElement
{
AttributeName = "Type",
KeyType = "RANGE"
},
},
ProvisionedThroughput = new ProvisionedThroughput
{
ReadCapacityUnits = 10,
WriteCapacityUnits = 5
},
};
var response = client.CreateTable(request);
Console.WriteLine("Table created with request ID: " +
response.ResponseMetadata.RequestId);
In the preceding example, the table is created through the AmazonDynamoDBClient class's CreateTable
method. The CreateTable method uses an instance of the CreateTableRequest class containing
characteristics such as required item attribute names, primary key definition, and throughput capacity.
The CreateTable method returns an instance of the CreateTableResponse class.
Before you begin modifying a table, you should make sure that the table is ready. The following example
shows how to use the low-level model to verify that a table in DynamoDB is ready:
// using Amazon.DynamoDBv2;
// using Amazon.DynamoDBv2.Model;
var client = new AmazonDynamoDBClient();
var status = "";
do
{
// Wait 5 seconds before checking (again).
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
try
{
var response = client.DescribeTable(new DescribeTableRequest
{
TableName = "AnimalsInventory"
});
Console.WriteLine("Table = {0}, Status = {1}",
response.Table.TableName,
response.Table.TableStatus);
status = response.Table.TableStatus;
}
catch (ResourceNotFoundException)
{
// DescribeTable is eventually consistent. So you might
// get resource not found.
Version v2.0.0
48
AWS SDK for .NET Developer Guide
Programming Models