AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 Amazon AWS 入门。
步骤 10:删除 Movies 表
在 Microsoft .NET 和 DynamoDB 教程的本步骤中,您将在 Amazon DynamoDB 中删除一个 Movies
表。
DynamoDB_intro
中的 Main
函数将等待 DeletingTable_async
,DeletingTable_async 在 10_DeletingTable.cs
文件中实施:
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
删除表。
了解更多信息
-
要了解有关读写 DynamoDB 表中的数据的更多信息,请参阅在 DynamoDB 中处理项目。
-
有关 DynamoDB 文档模型 API 的更多信息,请参阅 .NET:文档模型文档。
-
有关异步方法的更多信息,请参阅适用于 .NET 的 AWS 异步 API。