[英]How to filter by part of value using OData?
I have a table where lies some data and I change shown data according to some conditions (using OData). 我有一个表,其中放有一些数据,并根据某些条件(使用OData)更改了显示的数据。 For example:
例如:
"(LastDate eq null or LastDate ge datetime'" + date + "')"
or 要么
"Status eq 0"
Now I need to filer what is shown in my table by some value from textbox and there are problem. 现在,我需要通过文本框的某些值来过滤表中显示的内容,这是有问题的。 I have used second thing:
我用了第二件事:
"(Order eq '" + search + "' or SellerName eq '" + search + "' or ItemType eq '" + search + "' or ItemDescription eq '" + search + "')"
Works fine EXCEPT that this is eq. 可以正常工作,除非这是等式。 I need to find item not only by full match.
我不仅需要完全匹配来查找项目。 I saw that there could be used so called contains , but I didn't get how it supposed to look if I have many
or
. 我看到可以使用所谓的容器 ,但是如果我有许多
or
容器,我并没有得到应该的外观。 And... I simply reveived An unknown function with name 'contains' was found
error. 而且...我只是简单地
An unknown function with name 'contains' was found
出错。
How can I accomplish this? 我该怎么做?
the .net implementation of OData has support for "substringof" that works the same as you would expect a contains to work. OData的.net实现支持“ substringof”,其作用与您期望包含包含的作用相同。 eg:
例如:
filter=substringof(SellerName, ‘urn’)
Returns records with SellerNames containing the string “urn”. 返回带有包含字符串“ urn”的SellerNames的记录。
You can or them togeather like what you have already with eq. 您可以让他们像使用eq一样团结起来。
filter=substringof(SellerName, ‘urn’) or substringof(Order, ‘urn’)
See here for more details: https://msdn.microsoft.com/en-us/library/hh169248%28v=nav.80%29.aspx 请参阅此处以了解更多详细信息: https : //msdn.microsoft.com/zh-cn/library/hh169248%28v=nav.80%29.aspx
Please try this below var columnVal = value.toLowerCase(); 请在var columnVal = value.toLowerCase();下尝试此操作。
?$filter= (indexof(tolower(COLUMN_ID), columnVal)) gt -1 ?$ filter =(indexof(tolower(COLUMN_ID),columnVal))gt -1
This is working for me. 这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.