I am trying to use not in
operator in odata.
So does it support or not?
If yes then could you please give some example.
I was going through this post and trying but could not success. https://github.com/OData/odata.net/issues/1478
I am trying to use not in
operator in odata.
So does it support or not?
If yes then could you please give some example.
I was going through this post and trying but could not success. https://github.com/OData/odata.net/issues/1478
the comments in the linked git hub issue https://github.com/OData/odata.net/issues/1478 actually demonstrates that there are variations of support for NOT IN, even though there is not a single operator for it.
The .Net implementation of OData v4 does support the IN Operator for arrays of discreetly defined values, it does not Support a NOT-IN
style operator but it does have support for both NOT
and IN
.
NOT
simply negates the expression result but we can also replicate the NOT
functionality by equating the expression result with false
.
I can't find a publicly available sample to share, but my local projects do not have any trouble with the following queries:
Although redundant, the second query demonstrates that the result of IN
is a boolean expression and that you can further chain that expression with further conditions.
~/OData/Facilities?$filter=Entity/Title in ('Abbotsford','test')
~/OData/Facilities?$filter=Entity/Title in ('Abbotsford','test') eq true
returns:
{
"@odata.context": "http://localhost:16486/odata/$metadata#Facilities(FacilityType,Id,Entity(Title))",
"value": [
{
"FacilityType": "None",
"Id": 1081,
"Entity": {
"Title": "Abbotsford"
}
},
{
"FacilityType": "None",
"Id": 2009,
"Entity": {
"Title": "test"
}
},
{
"FacilityType": "None",
"Id": 8046,
"Entity": {
"Title": "test"
}
}
]
}
~/OData/Facilities?$filter=not(Entity/Title in ('Abbotsford','test'))
~/OData/Facilities?$filter=Entity/Title in ('Abbotsford','test') eq false
{
"@odata.context": "http://localhost:16486/odata/$metadata#Facilities(FacilityType,Id,Entity(Title))",
"value": [
{
"FacilityType": "None",
"Id": 1065,
"Entity": {
"Title": "Sleepy Hollow Templestowe Lower"
}
},
{
"FacilityType": "None",
"Id": 13076,
"Entity": {
"Title": "Peach Meadows"
}
}
]
}
If you model has addressable collection or array
not(property in ('v1', 'v2'))
works – a_horse_with_no_name