2

I am using the method tableServiceContext.CreateQuery and now (After upgrading to Azure SDK 2.5) it says that *

Support for accessing Windows Azure Tables via WCF Data Services is now obsolete. It's recommended that you use the Microsoft.WindowsAzure.Storage.Table namespace for working with tables.

*

So can anyone suggest an alternative for this method in the Microsoft.WindowsAzure.Storage.Table namespace. I am sharing the code below

 TableServiceContext tableServiceContext = this.tableClient.GetTableServiceContext();
            var query = (from e in this.tableServiceContext.CreateQuery<AuditLoggerEntity>(tableName)
                         where e.PartitionKey == organizationGuid && e.QueueMessageStatus != "Completed" && e.Action == "UpdateIdentityClaim"
                         select e).Take(resultsPerPage).AsTableServiceQuery<AuditLoggerEntity>(tableServiceContext);

            // Get the next continuation token
            var response = query.EndExecuteSegmented(query.BeginExecuteSegmented(nextToken, null, null));

The TableServiceContext class is also deprecated.

Ajay Bhasy
  • 1,920
  • 1
  • 26
  • 38

1 Answers1

4

Take a look at CloudTable.CreateQuery. Here's a sample code which makes use of it:

        var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
        var tableClient = account.CreateCloudTableClient();
        var table = tableClient.GetTableReference("Address");
        var tableQuery = from e in table.CreateQuery<DynamicTableEntity>()
            where e.PartitionKey == "Address"
            select e;
        var queryResult = tableQuery.AsTableQuery().ExecuteSegmented(null).ToList();
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • What is the difference between query.EndExecuteSegmented(query.BeginExecuteSegmented(nextToken, null, null)); AND tableQuery.AsTableQuery().ExecuteSegmented(null) – Ajay Bhasy Aug 05 '15 at 10:51
  • Begin/End is async implementation where as ExecuteSegmented is sync implementation. For async implementation, better alternative would be to use ExecuteSegmentedAsync – Gaurav Mantri Aug 05 '15 at 10:54
  • CreateQuery does not seem to be around any more and your link to the subject is 404'd. Is there a new way to do this? – crthompson Jul 02 '19 at 22:29
  • Looks like CreateQuery is not available in .Net Core (3 or earlier) https://stackoverflow.com/a/42942377/2589202 – crthompson Jul 02 '19 at 22:32