TableServiceContext.CreateQuery 的替代方案

Alternative for TableServiceContext.CreateQuery

我正在使用方法 tableServiceContext.CreateQuery,现在(升级到 Azure SDK 2.5 后)它说 *

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.

*

因此,任何人都可以在 Microsoft.WindowsAzure.Storage.Table 命名空间中提出此方法的替代方案。我正在分享下面的代码

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

TableServiceContext class 也已弃用。

看看CloudTable.CreateQuery。这是一个使用它的示例代码:

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