【发布时间】:2014-09-19 14:42:35
【问题描述】:
我有一个支持 OData 的 WebAPI 2.2 服务。
我的控制器有一个返回IQuerable<Entity> 的操作,但即使我允许所有功能,我也无法使用$filter=substringof 功能。
[Authorize]
public class MyController : ODataController
{
[EnableQuery(AllowedFunctions=AllowedFunctions.All)]
public IQueryable<Entity> GetEntities()
{
return GetMyQueryable();
}
}
当我点击像 http://localhost:49844/Entities/?$filter=substringof('Queen',Name) 这样的 URL 时
我收到一条错误消息,指出不允许使用 substringof。
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. An unknown function with name 'substringof' was found. This may also be a function import or a key lookup on a navigation property, which is not allowed.",
"innererror": {
"message": "An unknown function with name 'substringof' was found. This may also be a function import or a key lookup on a navigation property, which is not allowed.",
"type": "Microsoft.OData.Core.ODataException",
知道为什么我会看到这个错误吗?
【问题讨论】:
标签: asp.net-web-api odata