示例#1
0
        private void CreateTable(bool defaultKeys)
        {
            var keySchema = new List <KeySchemaElement>
            {
                new KeySchemaElement
                {
                    AttributeName = "Id",
                    KeyType       = KeyType.HASH
                },
                new KeySchemaElement
                {
                    AttributeName = defaultKeys ? "Name" : "Coffee",
                    KeyType       = KeyType.RANGE
                }
            };

            var attributes = new List <AttributeDefinition>
            {
                new AttributeDefinition
                {
                    AttributeName = "Id",
                    AttributeType = ScalarAttributeType.N
                },
                new AttributeDefinition
                {
                    AttributeName = defaultKeys ? "Name" : "Coffee",
                    AttributeType = ScalarAttributeType.S
                }
            };

            client.CreateTableAsync(new CreateTableRequest
            {
                TableName             = tableName,
                KeySchema             = keySchema,
                AttributeDefinitions  = attributes,
                ProvisionedThroughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits  = 5,
                    WriteCapacityUnits = 5
                }
            }).Wait();

            DynamoDBTests.WaitForTableStatus(client, tableName, TableStatus.ACTIVE);
        }
示例#2
0
 private void DeleteTable()
 {
     client.DeleteTableAsync(tableName).Wait();
     DynamoDBTests.WaitForTableStatus(client, tableName, null);
 }
示例#3
0
 private void DeleteTable(string name)
 {
     client.DeleteTableAsync(name).Wait();
     DynamoDBTests.WaitForTableStatus(client, name, null);
 }