serge
serge

Reputation: 15219

How to use WindowsAzure.Storage.Table in .NET Core projects?

I installed the Windows Azure Storage 8.1.4 NuGet package in my newly created ASP.NET Core Web project, in Visual Studio 2017.

Actually I try to use it, like the Microsoft docmentation suggests(table.ExecuteQuery(query)), but have only the "Async" methods:

enter image description here

The code:

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();
    }

I found there were similar problems in the past, like this one...

Any idea how to workaround this?

Upvotes: 1

Views: 702

Answers (1)

Naresh Podishetty
Naresh Podishetty

Reputation: 797

@Serge .NET Core doesn't yet include Sync Implementation of the APIs. so you can use ExecuteQuerySegmentedAsync instead. check this

The article you're following also doesn't say that it is for .NET Core.

enter image description here

Upvotes: 1

Related Questions