01-CreateTable .cs - Amazon DynamoDB
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

01-CreateTable .cs

01-CreateTable.cs 程序创建一个表 (TryDaxTable)。本部分的其他 .NET 程序都将依赖此表。

using System; using System.Collections.Generic; using System.Threading.Tasks; using Amazon.DynamoDBv2; using Amazon.DynamoDBv2.Model; namespace ClientTest { class Program { public static async Task Main(string[] args) { AmazonDynamoDBClient client = new AmazonDynamoDBClient(); var tableName = "TryDaxTable"; var request = new CreateTableRequest() { TableName = tableName, KeySchema = new List<KeySchemaElement>() { new KeySchemaElement{ AttributeName = "pk",KeyType = "HASH"}, new KeySchemaElement{ AttributeName = "sk",KeyType = "RANGE"} }, AttributeDefinitions = new List<AttributeDefinition>() { new AttributeDefinition{ AttributeName = "pk",AttributeType = "N"}, new AttributeDefinition{ AttributeName = "sk",AttributeType = "N"} }, ProvisionedThroughput = new ProvisionedThroughput() { ReadCapacityUnits = 10, WriteCapacityUnits = 10 } }; var response = await client.CreateTableAsync(request); Console.WriteLine("Hit <enter> to continue..."); Console.ReadLine(); } } }