gpt4 book ai didi

c# - TableServiceContext.CreateQuery 的替代方案

转载 作者:行者123 更新时间:2023-11-30 20:41:58 27 4
gpt4 key购买 nike

我正在使用 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 类也已弃用。

最佳答案

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

关于c# - TableServiceContext.CreateQuery 的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31827750/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com