AWS Code Sample
Catalog

02-Write-Data.cs

/** * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * This file is licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. A copy of * the License is located at * * http://aws.amazon.com/apache2.0/ * * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ 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(); } } }

Sample Details

Service: dynamodb

Last tested:

Author: AWS

Type: full-example

On this page: