2

以下是用于从 azure 表中获取数据的代码:

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString);
 CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
 TableServiceContext serviceContext = tableClient.GetDataServiceContext();
 CloudTableQuery<Customer> partitionQuery =
                (from e in serviceContext.CreateQuery<Customer>("Customer")
                 select e).AsTableServiceQuery<Customer>();

// Loop through the results, displaying information about the entity
   foreach (Customer entity in partitionQuery)
   {
        CustomerList.Add(entity);
   }

一切正常。突然我观察到,上面的调用没有返回任何东西。它能够获取ServiceContext。我尝试使用"Fidler"工具进行故障排除。实际上数据来自云表(我在 Fidler 的查询响应中看到)。但是当我迭代"partitionQuery"对象时,它返回时没有数据。相同的代码适用于其他机器。在其他机器上使用的 Azure SDK 也是一样的。有人可以帮忙吗?谢谢。

更新:现在我正在使用新版本的 Azure SDK。(2012 年 10 月)这可能是个问题吗?

4

2 回答 2

1

我遇到过同样的问题。当我指定分区键(或任何其他查询)时,它工作得很好。

rangeQuery = new TableQuery<PhotoEvent>().Where(TableQuery.GenerateFilterConditionForBool("active", QueryComparisons.Equal, true));
于 2012-11-24T06:04:11.820 回答
1

如果您使用的是 2012 年 10 月的 Azure SDK,您想要更改:

TableServiceContext serviceContext = tableClient.GetDataServiceContext();

CloudTableQuery<Customer> partitionQuery = (from e in serviceContext.CreateQuery<Customer>("Customer")
select e).AsTableServiceQuery<Customer>();

TableServiceContext serviceContext = tableClient.GetTableServiceContext();

TableServiceQuery<Customer > partitionQuery = (from e in serviceContext.CreateQuery<Customer>(“Customer”)
                                                               select e).AsTableServiceQuery(serviceContext);

注意:请参阅更详细的重大更改列表

另外,请确保您已包含Microsoft.WindowsAzure.Storage.Table.DataServices命名空间。

如果您仍然观察到意外行为,请提供提琴手跟踪(通过电子邮件),以便我们可以进一步调查。

于 2012-11-26T21:09:55.977 回答