从azure storage上取出的数据如果数据记录为0时进行ToList()时出错。
public IEnumerable RetrieveTableEntitiesInCondition(string tableName, string conditions) where TEntity : ITableEntity, new()
{
IEnumerable entities = null;
try
{
CloudTable table = tableClient.GetTableReference(tableName);
TableQuery query = new TableQuery().Where(conditions);
entities = table.ExecuteQuery(query);
}
catch (Exception ex)
{
logger.Warn("Retrieve condition entity failed: {0}.", ex.ToString());
}
return entities;
}
当该数据记录为0时对该结果进行ToList()操作时抛出异常,异常为:The remote server returned an error: (404) Not Found. Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
求大神帮忙解答为什么ToList()操作会抛出这么个异常。
从azure storage上取出的数据如果数据记录为0时进行ToList()时出错。
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- JamborYao_MSFT 2015-10-16 02:58关注
Hi,
据我测试在特定的condition下返回数据为0时我们依然可以使用ToList(),并不会报错,下面是我尝试的代码,稍有改动。
public IEnumerable<TEntity> RetrieveTableEntitiesInCondition<TEntity>(string tableName, string conditions ) where TEntity : TableEntity, new() { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this._stroageConnectionCN); var tableClient = storageAccount.CreateCloudTableClient(); IEnumerable<TEntity> entities = null; try { CloudTable table = tableClient.GetTableReference(tableName); TableQuery<TEntity> query = new TableQuery<TEntity>().Where(conditions); entities = table.ExecuteQuery(query); } catch (Exception ex) { // logger.Warn("Retrieve condition entity failed: {0}.", ex.ToString()); } return entities; }
上面图片也可以看出在没有结果的情况下list得到了一个Count为0的集合,从你的错误的详细情况(remote server returned an error: (404) Not Found. )来看,这个问题的原因可能是由于一些其他问题造成的,我建议你首先检查下你的网络环境,然后再次核对下storage connection是否被串改。Best Regards,
Jambor
如果您想进一步了解Windows Azure, Windows Azure 官网欢迎您的访问本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥20 腾讯企业邮箱邮件可以恢复么
- ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
- ¥15 错误 LNK2001 无法解析的外部符号
- ¥50 安装pyaudiokits失败
- ¥15 计组这些题应该咋做呀
- ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
- ¥15 让node服务器有自动加载文件的功能
- ¥15 jmeter脚本回放有的是对的有的是错的
- ¥15 r语言蛋白组学相关问题
- ¥15 Python时间序列如何拟合疏系数模型