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

步骤 10:删除 Movies 表

Microsoft .NET 和 DynamoDB 教程的本步骤中,您将在 Amazon DynamoDB 中删除一个 Movies 表。

DynamoDB_intro 中的 Main 函数将等待 DeletingTable_async,DeletingTable_async 在 10_DeletingTable.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 System; using System.Threading.Tasks; namespace DynamoDB_intro { public static partial class Ddb_Intro { /*-------------------------------------------------------------------------- * DeletingTable_async *--------------------------------------------------------------------------*/ public static async Task<bool> DeletingTable_async( string tableName ) { operationSucceeded = false; operationFailed = false; Console.WriteLine( " -- Trying to delete the table named \"{0}\"...", tableName ); pause( ); Task tblDelete = client.DeleteTableAsync( tableName ); try { await tblDelete; } catch( Exception ex ) { Console.WriteLine( " ERROR: Failed to delete the table, because:\n " + ex.Message ); operationFailed = true; return ( false ); } Console.WriteLine( " -- Successfully deleted the table!" ); operationSucceeded = true; pause( ); return ( true ); } }

DeletingTable_async 等待低级别 DynamoDB 方法 AmazonDynamoDBClient.DeleteTableAsync 删除表。

了解更多信息

本页内容: