我收到此错误:找不到段“GetTest”的资源。
代码是这样的:
[WebGet]
public IQueryable<string> GetTest()
{
var tmp = new List<string>();
return tmp.AsQueryable();
}
知道哪里出了问题吗?
最佳答案
当查找不存在的主键时出现“找不到该段的资源”
用try-catch试试
try
{
var tmp = new List<string>();
return tmp.AsQueryable();
}
catch( DataServiceQueryException ex )
{
return null;
}
关于c# - 找不到段 'x' 的资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8242605/