OData V6.6.0不允许$ search(OData V6.6.0 is not allowing $search)

编程入门 行业动态 更新时间:2024-10-27 18:31:17
OData V6.6.0不允许$ search(OData V6.6.0 is not allowing $search)

我正在尝试使用OData V6.6.0 $搜索功能。 我最初有5.2版本,我更新到6.6.0版本。 但是,我仍然无法使用$ search。 当我在url中使用它时

odata/Prescribers?$inlinecount=allpages&$top=20&$search=TEST';

我收到此错误消息'不支持查询参数'$ search'。

我是否需要执行其他操作才能添加$ search功能。 顺便说一句,我也在我的控制器中使用EnableQuery。

[EnableQuery(AllowedQueryOptions = System.Web.Http.OData.Query.AllowedQueryOptions.All)] public IQueryable<ContactList> Get() { return dbContext.ContactsList.AsQueryable(); }

I'm trying to use OData V6.6.0 $search functionality. I initially had version 5.2 which I updated to version 6.6.0. However, I still am not able to use $search. When I use it in url

odata/Prescribers?$inlinecount=allpages&$top=20&$search=TEST';

I get this error message 'The query parameter '$search' is not supported.'

Do I need to do something else in order to add $search functionality. Btw, I'm also using EnableQuery in my Controller like this.

[EnableQuery(AllowedQueryOptions = System.Web.Http.OData.Query.AllowedQueryOptions.All)] public IQueryable<ContactList> Get() { return dbContext.ContactsList.AsQueryable(); }

最满意答案

WebApi目前不支持$ search。 为了支持它,你可以从这里开始https://aspnetwebstack.codeplex.com/SourceControl/latest#OData/src/System.Web.OData/OData/Query/ODataQueryOptions.cs来模拟其他查询选项,然后引用你私人建的DLL。

I figured it out. If substringof is used in the filter then it returns the records of value containing the string. I used $filter with 'or' operator to check multiple columns.

'&$filter=substringof(\'' + key + '\', NPI)' + 'or substringof(\'' + key + '\', Zip)' + 'or substringof(\'' + key + '\', PrescriberName)';

This displayed all the records that contains the string in the filter.

更多推荐

本文发布于:2023-07-23 04:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1227575.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不允许   OData   allowing   search

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!