简体   繁体   English

“不包含”运算符的 Odata 过滤器

[英]Odata filter for "does not contain" operator

I have tried finding but I am unable to figure out what the equivalent OData filter string would be for the "Does not contain" operator.我曾尝试查找,但无法弄清楚“不包含”运算符的等效 OData 过滤器字符串是什么。 This is what I did for the "Contains" operator:这是我为“包含”运算符所做的:

case FilterOperator.Contains:
                    odataFilter = $"contains({queryFilter.FieldName}, '{value}')";
                    break; 

odataFilter = $"indexof({queryFilter.FieldName}, '{value}') eq -1";

This will returns entities where the value in FieldName does not contain value .这将返回FieldName中的值不包含value的实体。

The indexof function will return -1 if the specified string in the second parameter could not be found in the field specified in the first parameter.如果在第一个参数指定的字段中找不到第二个参数中指定的字符串, indexof function 将返回 -1。

See the reference to the technical documentation for more information:有关详细信息,请参阅技术文档参考:
https://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html#_Toc371341777 https://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part2-url-conventions.html#_Toc371341777

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM