gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 02:03:26 29 4
gpt4 key购买 nike

我有一个支持 OData 的 WebAPI 2.2 服务。

我的 Controller 有一个返回 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",

知道为什么我会看到此错误吗?

最佳答案

substringof() 是一个 V3 函数,而 contains() 是一个 V4 函数。

尝试包含:

$filter=contains(Name,'Queen')

关于asp.net-web-api - WebAPI 2.2 不支持 substringof 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24994774/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com