我安装了 Windows Azure Storage 8.1.4我在 Visual Studio 2017 中新创建的 ASP.NET Core Web 项目中的 NuGet 包。
实际上我尝试使用它,例如 Microsoft docmentation建议(table.ExecuteQuery(query)
),但只有“异步”方法:
代码:
public class HelloWorldController : Controller
{
public string ReadTables() {
CloudStorageAccount storage = CloudStorageAccount.Parse(connStr.MyTablesConnStr);
CloudTableClient tableClient = storage.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("themes");
StringBuilder response = new StringBuilder("Here is your test Table:");
var query = new TableQuery<ProjectThemeEntity>() {
SelectColumns = new List<string> {"RowKey", "Description" }
};
// No way to do it in the controller action ?! ----------
var items=await table.ExecuteQuerySegmentedAsync<ProjectThemeEntity>(query, null);
foreach (ProjectThemeEntity item in items) {
response.AppendLine($"Key: {item.RowKey}; Value: {item.Description}");
}
return response.ToString();
}
我发现过去也有类似的问题,比如this one ...
知道如何解决这个问题吗?
最佳答案
关于azure - 如何在.NET Core项目中使用WindowsAzure.Storage.Table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45041294/