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

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

02-Write-Data.cs

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

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"; 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 = await client.PutItemAsync(request); } } Console.WriteLine("Hit <enter> to continue..."); Console.ReadLine(); } } }