winforms 如何在C#中查看DynamoDB表名?

ux6nzvsh  于 2023-01-31  发布在  C#
关注(0)|答案(1)|浏览(161)

我看不到已经创建的表的名称。我正在处理一个项目,在该项目中,我可以通过IAM客户端访问DynamoDB数据库,我使用提供给我的凭据和配置创建了AmazonClient,但我看不到数据库中已经创建的表。
我已经创建了客户端并将其连接到数据库,我尝试查看表的数量,如下所示,但结果总是0
new code

List<string> currentTables = client.ListTablesAsync().Result.TableNames;
MessageBox.Show(currentTables.Count.ToString());
laximzn5

laximzn51#

尝试等待API调用:

List<string> currentTables = await client.ListTablesAsync().Result.TableNames;
            MessageBox.Show(currentTables.Count.ToString());

请尝试使用此同步代码:

AmazonDynamoDBClient client = new AmazonDynamoDBClient();

// Initial value for the first page of table names.
string lastEvaluatedTableName = null;
do
{
   // Create a request object to specify optional parameters.
   var request = new ListTablesRequest
   {
     Limit = 10, // Page size.
     ExclusiveStartTableName = lastEvaluatedTableName
   };

   var response = client.ListTables(request);
   ListTablesResult result = response.ListTablesResult;
   foreach (string name in result.TableNames)
     Console.WriteLine(name);

   lastEvaluatedTableName = result.LastEvaluatedTableName;

} while (lastEvaluatedTableName != null);

相关问题