我在Visual Studio 2017中新创建的ASP.NET Core Web项目中安装了Windows Azure Storage 8.1.4 NuGet包。
实际上我尝试使用它,就像Microsoft docmentation建议(table.ExecuteQuery(query)
)一样,但只有#34; Async"方法:
代码:
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 ...
知道如何解决这个问题吗?
答案 0 :(得分:1)