Amazon DynamoDB
开发人员指南 (API 版本 2012-08-10)
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

02-Write-Data.cs

02-Write-Data.cs 程序向 TryDaxTable 中写入测试数据。

using Amazon.DynamoDBv2.Model; using System.Collections.Generic; using System; using Amazon.DynamoDBv2; namespace ClientTest { class Program { static void Main(string[] args) { AmazonDynamoDBClient client = new AmazonDynamoDBClient(); var tableName = "TryDaxTable"; string someData = new String('X', 1000); var pkmax = 10; var skmax = 10; for (var ipk = 1; ipk <= pkmax; ipk++) { Console.WriteLine("Writing " + skmax + " items for partition key: " + ipk); for (var isk = 1; isk <= skmax; isk++) { var request = new PutItemRequest() { TableName = tableName, Item = new Dictionary<string, AttributeValue>() { { "pk", new AttributeValue{N = ipk.ToString() } }, { "sk", new AttributeValue{N = isk.ToString() } }, { "someData", new AttributeValue{S = someData } } } }; var response = client.PutItemAsync(request).Result; } } Console.WriteLine("Hit <enter> to continue..."); Console.ReadLine(); } } }