AWS Code Sample


/** * Copyright 2010-2019, 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 * * * * 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 System; using System.Text; using Amazon.DynamoDBv2; using Amazon.DynamoDBv2.Model; namespace DynamoDB_intro { class Program { static void Main(string[] args) { // Get an AmazonDynamoDBClient for the local DynamoDB database AmazonDynamoDBClient client = GetLocalClient(); try { client.DeleteTable("Movies"); } catch (Exception ex) { Console.WriteLine("\n Error: the \'Movies\" table could not be deleted!\n Reason: " + ex.Message); Console.Write("\n\n ...Press any key to continue"); Console.ReadKey(); Console.WriteLine(); return; } Console.WriteLine("\n Deleted the \'Movies\" table successfully!"); } public static AmazonDynamoDBClient GetLocalClient() { // First, set up a DynamoDB client for DynamoDB Local AmazonDynamoDBConfig ddbConfig = new AmazonDynamoDBConfig(); ddbConfig.ServiceURL = "http://localhost:8000"; AmazonDynamoDBClient client; try { client = new AmazonDynamoDBClient(ddbConfig); } catch (Exception ex) { Console.WriteLine("\n Error: failed to create a DynamoDB client; " + ex.Message); return (null); } return (client); } } }

Sample Details

Service: dynamodb

Last tested:

Author: AWS

Type: full-example

On this page: