【发布时间】:2020-07-17 15:53:01
【问题描述】:
我正在尝试使用 C# 函数从 Azure 表存储中读取数据,并遵循此答案 (How to get all rows in Azure table Storage in C#?) 中列出的指南。但是,在我的代码的最后一行,我收到以下错误:
CloudTable 不包含 ExecuteQuery 的定义
下面是我的代码:
var creds = new StorageCredentials(accountName, accountKey);
var account = new CloudStorageAccount(creds, useHttps: true);
// Retrieve the role assignments table
var client = account.CreateCloudTableClient();
var table = client.GetTableReference("RoleAssignmentTable");
var entities = table.ExecuteQuery(new TableQuery<RoleAssignment>()).ToList();
我正在使用Azure Functions v2.0 和.NET Core SDK 3.1.302
【问题讨论】:
-
您所针对的 .Net 版本似乎存在问题:github.com/Azure/azure-storage-net/issues/684
-
您可能没有使用最新且正确的连接 .Net 控件? nuget.org/profiles/azure-sdk
-
可能会尝试 var entity = (await table.ExecuteQuerySegmentedAsync(new TableQuery
(), null)).ToList(); //假设你在一个异步方法中