我正在尝试使用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.
更多推荐
发布评论