asp.net-web-api – WebAPI 2.2不支持substringof函数

前端之家收集整理的这篇文章主要介绍了asp.net-web-api – WebAPI 2.2不支持substringof函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个支持OData的WebAPI 2.2服务。

我的控制器有一个返回IQuerable< Entity>的操作,但即使我允许所有的功能,我也无法使用$ filter = substringof函数。@H_301_3@

[Authorize]
public class MyController : ODataController
{
    [EnableQuery(AllowedFunctions=AllowedFunctions.All)]
    public IQueryable<Entity> GetEntities()
    {
      return GetMyQueryable();
    }
}

当我点击http:// localhost:49844 / Entities /?$ filter = substringof(‘Queen’,Name)时,@H_301_3@

我得到一个错误,表示substringof是不允许的。@H_301_3@

{
"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,"type": "Microsoft.OData.Core.ODataException",

任何想法为什么我可能会看到这个错误?@H_301_3@

解决方法

substringof()是V3函数,而contains()是V4函数

尝试包含:@H_301_3@

$filter=contains(Name,'Queen')
原文链接:https://www.f2er.com/aspnet/252908.html

猜你在找的asp.Net相关文章