对azure表的查询不返回任何数据
以下是用于从azure表获取数据的代码:对azure表的查询不返回任何数据,azure,azure-storage,azure-table-storage,Azure,Azure Storage,Azure Table Storage,以下是用于从azure表获取数据的代码: CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); TableServiceContext serviceContext = tableClient.GetDataServiceContext();
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);
}
CloudStorageAccount-storageAccount=CloudStorageAccount.Parse(ConnectionString);
CloudTableClient tableClient=storageAccount.CreateCloudTableClient();
TableServiceContext serviceContext=tableClient.GetDataServiceContext();
CloudTableQuery分区查询=
(来自serviceContext.CreateQuery(“客户”)中的e)
选择e).AsTableServiceQuery();
//循环浏览结果,显示有关实体的信息
foreach(partitionQuery中的客户实体)
{
CustomerList.Add(实体);
}
一切正常。突然我注意到,上面的调用并没有返回任何内容。
它能够获取ServiceContext。我尝试使用“Fidler”
工具进行故障排除。实际上,数据来自云表(我在Fidler中的查询响应中看到)。但是当我迭代“partitionQuery”
对象时,它返回时没有数据。同样的代码适用于其他机器。其他机器中使用的Azure SDK也是相同的。有人能帮忙吗?谢谢
更新:现在我正在使用新版本的Azure SDK。(2012年10月)这可能是个问题吗?我也遇到过同样的问题。当我指定一个分区键(或任何其他查询)时,它工作得很好
rangeQuery = new TableQuery<PhotoEvent>().Where(TableQuery.GenerateFilterConditionForBool("active", QueryComparisons.Equal, true));
rangeQuery=new TableQuery().Where(TableQuery.GenerateFilterConditionForBool(“active”,QueryComparisons.Equal,true));
如果您正在使用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.GetDataServiceContext();
CloudTableQuery partitionQuery=(来自serviceContext.CreateQuery(“客户”)中的e)
选择e).AsTableServiceQuery();
到
TableServiceContext serviceContext=tableClient.GetTableServiceContext();
TableServiceQuery partitionQuery=(来自serviceContext.CreateQuery(“客户”)中的e)
选择e).AsTableServiceQuery(serviceContext);
注:见a
另外,请确保已包含Microsoft.WindowsAzure.Storage.Table.DataServices
命名空间
如果您仍在观察意外行为,请提供fiddler跟踪(通过电子邮件),以便我们进一步调查。是因为版本更改吗?
TableServiceContext serviceContext = tableClient.GetTableServiceContext();
TableServiceQuery<Customer > partitionQuery = (from e in serviceContext.CreateQuery<Customer>(“Customer”)
select e).AsTableServiceQuery(serviceContext);