从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 官网欢迎您的访问本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog