From 228ba9522c051e514f408796f0ef7f9b3aa8c8e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Heiko=20Thei=C3=9Fen?= OData-JSON, section 18, and in the resource path parentheses after the function name MUST be omitted.
Example 52: An employee’s top ten leave requests from now to the end of the year pending their manager’s approval. Compare this with example 30.
-POST http://host/service/Employees(23)/self.PendingLeaveRequests/$query
+Example 52: The same request as in example 50 can be sent with application/json
encoding using the following payload:
+POST http://host/service/People/$query
Content-Type: application/json
{
-"StartDate@expression": "now()",
- "EndDate": "2024-12-31",
- "Approver@expression": "Manager",
- "$top": 10
- }
+"$filter": "LastName eq 'P&G'",
+ "$select": "FirstName,LastName"
+ }
Members of the JSON object also include parameters if the resource path is a function invocation or function import. In this case parameters MUST be represented like parameters in an action invocation OData-JSON, section 18, and in the resource path parentheses after the function name MUST be omitted.
+Example 53: An employee’s top ten leave requests from now to the end of the year pending their manager’s approval. Compare this with example 30.
+POST http://host/service/Employees(23)/self.PendingLeaveRequests/$query
+Content-Type: application/json
+
+{
+"StartDate@expression": "now()",
+ "EndDate": "2024-12-31",
+ "Approver@expression": "Manager",
+ "$top": 10
+ }
The following examples illustrate the use and semantics of each of the logical operators.
Example 53: all products with a Name
equal to Milk
Example 54: all products with a Name
equal to Milk
http://host/service/Products?$filter=Name eq 'Milk'
Example 54: all products with a Name
not equal to Milk
Example 55: all products with a Name
not equal to Milk
http://host/service/Products?$filter=Name ne 'Milk'
Example 55: all products with a Name
greater than Milk
:
Example 56: all products with a Name
greater than Milk
:
http://host/service/Products?$filter=Name gt 'Milk'
Example 56: all products with a Name
greater than or equal to Milk
:
Example 57: all products with a Name
greater than or equal to Milk
:
http://host/service/Products?$filter=Name ge 'Milk'
Example 57: all products with a Name
less than Milk
:
Example 58: all products with a Name
less than Milk
:
http://host/service/Products?$filter=Name lt 'Milk'
Example 58: all products with a Name
less than or equal to Milk
:
Example 59: all products with a Name
less than or equal to Milk
:
http://host/service/Products?$filter=Name le 'Milk'
Example 59: all products with a Name
equal to Milk
that also have a Price
less than 2.55:
Example 60: all products with a Name
equal to Milk
that also have a Price
less than 2.55:
http://host/service/Products?$filter=Name eq 'Milk' and Price lt 2.55
Example 60: all products that either have a Name
equal to Milk
or have a Price
less than 2.55:
Example 61: all products that either have a Name
equal to Milk
or have a Price
less than 2.55:
http://host/service/Products?$filter=Name eq 'Milk' or Price lt 2.55
Example 61: all products that do not have a Name
that ends with ilk
:
Example 62: all products that do not have a Name
that ends with ilk
:
http://host/service/Products?$filter=not endswith(Name,'ilk')
Example 62: all products whose style
value includes Yellow
:
Example 63: all products whose style
value includes Yellow
:
http://host/service/Products?$filter=style has Sales.Pattern'Yellow'
Example 63: all products whose Name
is Milk
or Cheese
:
Example 64: all products whose Name
is Milk
or Cheese
:
http://host/service/Products?$filter=Name in ('Milk', 'Cheese')
The following examples illustrate the use and semantics of each of the Arithmetic operators.
Example 64: all products with a Price of 2.55:
+Example 65: all products with a Price of 2.55:
http://host/service/Products?$filter=Price add 2.45 eq 5.00
Example 65: all products with a Price of 2.55:
+Example 66: all products with a Price of 2.55:
http://host/service/Products?$filter=Price sub 0.55 eq 2.00
Example 66: all products with a Price of 2.55:
+Example 67: all products with a Price of 2.55:
http://host/service/Products?$filter=Price mul 2.0 eq 5.10
Example 67: all products with a Price of 2.55:
+Example 68: all products with a Price of 2.55:
http://host/service/Products?$filter=Price div 2.55 eq 1
Example 68: all products with an integer Rating value of 4 or 5:
+Example 69: all products with an integer Rating value of 4 or 5:
http://host/service/Products?$filter=Rating div 2 eq 2
Example 69: all products with an integer Rating value of 5:
+Example 70: all products with an integer Rating value of 5:
http://host/service/Products?$filter=Rating divby 2 eq 2.5
Example 70: all products with a Rating exactly divisible by 5:
+Example 71: all products with a Rating exactly divisible by 5:
http://host/service/Products?$filter=Rating mod 5 eq 0
The Grouping operator (open and close parenthesis “( )
”) controls the evaluation order of an expression. The Grouping operator returns the expression grouped inside the parenthesis.
Example 71: all products because 9 mod 3 is 0
+Example 72: all products because 9 mod 3 is 0
http://host/service/Products?$filter=(4 add 5) mod (4 sub 1) eq 0
concatThe concat function with collection parameter values returns a collection that appends all items of the second collection to the first. If both collections are ordered, the result is also ordered.
The concatMethodCallExpr
syntax rule defines how the concat
function is invoked.
-Example 72: all customers from Berlin, Germany
+Example 73: all customers from Berlin, Germany
http://host/service/Customers?$filter=concat(concat(City,', '),Country) eq 'Berlin, Germany'
@@ -1349,7 +1359,7 @@ 5.1.1.5.2 cont
The contains
function with ordered collection parameter values returns true if the first collection can be transformed into the second collection by removing zero or more items from the beginning or the end of the first collection.
The containsMethodCallExpr
syntax rule defines how the contains
function is invoked.
-Example 73: all customers with a CompanyName
that contains Alfreds
+Example 74: all customers with a CompanyName
that contains Alfreds
http://host/service/Customers?$filter=contains(CompanyName,'Alfreds')
@@ -1363,7 +1373,7 @@ 5.1.1.5.3 ends
The endswith
function with ordered collection parameter values returns true if the first collection can be transformed into the second collection by removing zero or more items from the beginning of the first collection.
The endsWithMethodCallExpr
syntax rule defines how the endswith
function is invoked.
-Example 74: all customers with a CompanyName
that ends with Futterkiste
+Example 75: all customers with a CompanyName
that ends with Futterkiste
http://host/service/Customers?$filter=endswith(CompanyName,'Futterkiste')
@@ -1377,7 +1387,7 @@ 5.1.1.5.4 indexof
The indexof
function with ordered collection parameter values returns the zero-based index of the first occurrence of the second collection in the first collection, or -1 if the first collection does not contain the second collection.
The indexOfMethodCallExpr
syntax rule defines how the indexof
function is invoked.
-Example 75: all customers with a CompanyName
containing lfreds
starting at the second character
+Example 76: all customers with a CompanyName
containing lfreds
starting at the second character
http://host/service/Customers?$filter=indexof(CompanyName,'lfreds') eq 1
@@ -1391,7 +1401,7 @@ 5.1.1.5.5 lengthThe length
function with a collection parameter value returns the number of itens in the collection.
The lengthMethodCallExpr
syntax rule defines how the length
function is invoked.
-Example 76: all customers with a CompanyName
that is 19 characters long
+Example 77: all customers with a CompanyName
that is 19 characters long
http://host/service/Customers?$filter=length(CompanyName) eq 19
@@ -1405,7 +1415,7 @@ 5.1.1.5.6 The startswith
function with ordered collection parameter values returns true if the first collection can be transformed into the second collection by removing zero or more items from the end of the first collection.
The startsWithMethodCallExpr
syntax rule defines how the startswith
function is invoked.
-Example 77: all customers with a CompanyName
that starts with Alfr
+Example 78: all customers with a CompanyName
that starts with Alfr
http://host/service/Customers?$filter=startswith(CompanyName,'Alfr')
@@ -1426,11 +1436,11 @@ 5.1.1.5.7 s
A negative start index N, if supported, returns a string/collection starting N characters/items before the end of the string/collection.
The substringMethodCallExpr
syntax rule defines how the substring
function is invoked.
-Example 78: all customers with a CompanyName
of lfreds Futterkiste
once the first character has been removed
+Example 79: all customers with a CompanyName
of lfreds Futterkiste
once the first character has been removed
http://host/service/Customers?$filter=substring(CompanyName,1) eq 'lfreds Futterkiste'
-Example 79: all customers with a CompanyName
that has lf
as the second and third characters, e.g, Alfreds Futterkiste
+Example 80: all customers with a CompanyName
that has lf
as the second and third characters, e.g, Alfreds Futterkiste
http://host/service/Customers?$filter=substring(CompanyName,1,2) eq 'lf'
@@ -1445,7 +1455,7 @@ 5.1.1.6.1 h
Edm.Boolean hassubset(Collection, Collection)
The hassubset
function returns true if the first collection can be transformed into the second collection by reordering and/or removing zero or more items. The hasSubsetMethodCallExpr
syntax rule defines how the hassubset
function is invoked.
-Example 80: hassubset
expressions that return true
+Example 81: hassubset
expressions that return true
hassubset([4,1,3],[4,1,3])
hassubset([4,1,3],[1,3,4])
hassubset([4,1,3],[3,1])
@@ -1453,7 +1463,7 @@ 5.1.1.6.1 h
hassubset([4,1,3,1],[1,1])
-Example 81: hassubset
expression that returns false: 1 appears only once in the left operand
+Example 82: hassubset
expression that returns false: 1 appears only once in the left operand
hassubset([1,2],[1,1,2])
@@ -1464,14 +1474,14 @@ 5.
Edm.Boolean hassubsequence(OrderedCollection,OrderedCollection)
The hassubsequence
function returns true if the first collection can be transformed into the second collection by removing zero or more items. The hasSubsequenceMethodCallExpr
syntax rule defines how the hassubsequence
function is invoked.
-Example 82: hassubsequence
expressions that return true
+Example 83: hassubsequence
expressions that return true
hassubsequence([4,1,3],[4,1,3])
hassubsequence([4,1,3],[4,1])
hassubsequence([4,1,3],[4,3])
hassubsequence([4,1,3,1],[1,1])
-Example 83: hassubsequence
expressions that return false
+Example 84: hassubsequence
expressions that return false
hassubsequence([4,1,3],[1,3,4])
hassubsequence([4,1,3],[3,1])
hassubsequence([1,2],[1,1,2])
@@ -1489,11 +1499,11 @@ 5.
Edm.Boolean matchespattern(Edm.String,Edm.String,Edm.String)
The second parameter MUST evaluate to a string containing an ECMAScript (JavaScript) regular expression. The matchespattern
function returns true if the first parameter evaluates to a string matching that regular expression, using syntax and semantics of ECMAScript regular expressions, otherwise it returns false. If the optional third parameter is provided, it MUST evaluate to a string consisting of ECMAScript regular expression flags to modify the match.
-Example 84: all customers with a CompanyName
that match the (percent-encoded) regular expression ^A.*e$
+Example 85: all customers with a CompanyName
that match the (percent-encoded) regular expression ^A.*e$
http://host/service/Customers?$filter=matchespattern(CompanyName,'%5EA.*e$')
-Example 85: all customers with a FormattedAddress
that contains a line ending with berg
or ends with berg
+Example 86: all customers with a FormattedAddress
that contains a line ending with berg
or ends with berg
http://host/service/Customers?$filter=matchespattern(FormattedAddress,'berg$','m')
@@ -1504,7 +1514,7 @@ 5.1.1.7.2 tolower
Edm.String tolower(Edm.String)
The tolower
function returns the input parameter string value with all uppercase characters converted to lowercase according to Unicode rules. The toLowerMethodCallExpr
syntax rule defines how the tolower
function is invoked.
-Example 86: all customers with a CompanyName
that equals alfreds futterkiste
once any uppercase characters have been converted to lowercase
+Example 87: all customers with a CompanyName
that equals alfreds futterkiste
once any uppercase characters have been converted to lowercase
http://host/service/Customers?$filter=tolower(CompanyName) eq 'alfreds futterkiste'
@@ -1515,7 +1525,7 @@ 5.1.1.7.3 toupper
Edm.String toupper(Edm.String)
The toupper
function returns the input parameter string value with all lowercase characters converted to uppercase according to Unicode rules. The toUpperMethodCallExpr
syntax rule defines how the toupper
function is invoked.
-Example 87: all customers with a CompanyName
that equals ALFREDS FUTTERKISTE
once any lowercase characters have been converted to uppercase
+Example 88: all customers with a CompanyName
that equals ALFREDS FUTTERKISTE
once any lowercase characters have been converted to uppercase
http://host/service/Customers?$filter=toupper(CompanyName) eq 'ALFREDS FUTTERKISTE'
@@ -1526,7 +1536,7 @@ 5.1.1.7.4 trim
<
Edm.String trim(Edm.String)
The trim
function returns the input parameter string value with all leading and trailing whitespace characters, according to Unicode rules, removed. The trimMethodCallExpr
syntax rule defines how the trim
function is invoked.
-Example 88: all customers with a CompanyName
without leading or trailing whitespace characters
+Example 89: all customers with a CompanyName
without leading or trailing whitespace characters
http://host/service/Customers?$filter=trim(CompanyName) eq CompanyName
@@ -1550,7 +1560,7 @@ 5.1.1.8.2 day
The day
function returns the day component Date
or DateTimeOffset
parameter value, evaluated in the time zone of the DateTimeOffset
parameter value. The dayMethodCallExpr
syntax rule defines how the day
function is invoked.
Services that are unable to preserve the offset of Edm.DateTimeOffset
values and instead normalize the values to some common time zone (for example UTC) MUST fail evaluation of the day
function for literal Edm.DateTimeOffset
values that are not stated in the time zone of the normalized values.
-Example 89: all employees born on the 8th day of a month
+Example 90: all employees born on the 8th day of a month
http://host/service/Employees?$filter=day(BirthDate) eq 8
@@ -1562,7 +1572,7 @@
-Example 90: all employees born less than 100 milliseconds after a full second of any minute of any hour on any day
+Example 91: all employees born less than 100 milliseconds after a full second of any minute of any hour on any day
http://host/service/Employees?$filter=[fractionalseconds(BirthDate) lt 0.1
@@ -1575,7 +1585,7 @@ 5.1.1.8.4 hour
<
The hour
function returns the hour component (0
to 23
) of the DateTimeOffset
or TimeOfDay
parameter value, evaluated in the time zone of the DateTimeOffset
parameter value. The hourMethodCallExpr
syntax rule defines how the hour
function is invoked.
Services that are unable to preserve the offset of Edm.DateTimeOffset
values and instead normalize the values to some common time zone (for example UTC) MUST fail evaluation of the hour
function for literal Edm.DateTimeOffset
values that are not stated in the time zone of the normalized values.
-Example 91: all employees born in hour 4, between 04:00 (inclusive) and 05:00 (exclusive)
+Example 92: all employees born in hour 4, between 04:00 (inclusive) and 05:00 (exclusive)
http://host/service/Employees?$filter=hour(BirthDate) eq 4
@@ -1601,7 +1611,7 @@ 5.1.1.8.7 minute
The minute
function returns the minute component (0
to 59
) of the DateTimeOffset
or TimeOfDay
parameter value, evaluated in the time zone of the DateTimeOffset
parameter value. The minuteMethodCallExpr
syntax rule defines how the minute
function is invoked.
-Example 92: all employees born in minute 40 of any hour on any day
+Example 93: all employees born in minute 40 of any hour on any day
http://host/service/Employees?$filter=minute(BirthDate) eq 40
@@ -1614,7 +1624,7 @@ 5.1.1.8.8 month
<
The month
function returns the month component of the Date
or DateTimeOffset
parameter value, evaluated in the time zone of the DateTimeOffset
parameter value. The monthMethodCallExpr
syntax rule defines how the month
function is invoked.
Services that are unable to preserve the offset of Edm.DateTimeOffset
values and instead normalize the values to some common time zone (for example UTC) MUST fail evaluation of the month
function for literal Edm.DateTimeOffset
values that are not stated in the time zone of the normalized values.
-Example 93: all employees born in May
+Example 94: all employees born in May
http://host/service/Employees?$filter=month(BirthDate) eq 5
@@ -1634,7 +1644,7 @@ 5.1.1.8.10 second
Edm.Int32 second(Edm.TimeOfDay)
The second
function returns the second component (0
to 59
for regular seconds, and 60
for leap seconds, without the fractional part) of the DateTimeOffset
or TimeOfDay
parameter value. The secondMethodCallExpr
syntax rule defines how the second
function is invoked.
-Example 94: all employees born in second 40 of any minute of any hour on any day
+Example 95: all employees born in second 40 of any minute of any hour on any day
http://host/service/Employees?$filter=second(BirthDate) eq 40
@@ -1669,7 +1679,7 @@ 5.1.1.8.14 year
The year
function returns the year component of the Date
or DateTimeOffset
parameter value, evaluated in the time zone of the DateTimeOffset
parameter value. The yearMethodCallExpr
syntax rule defines how the year
function is invoked.
Services that are unable to preserve the offset of Edm.DateTimeOffset
values and instead normalize the values to some common time zone (for example UTC) MUST fail evaluation of the year
function for literal Edm.DateTimeOffset
values that are not stated in the time zone of the normalized values.
-Example 95: all employees born in 1971
+Example 96: all employees born in 1971
http://host/service/Employees?$filter=year(BirthDate) eq 1971
@@ -1685,7 +1695,7 @@ 5.1.1.9.1 ceiling
Edm.Decimal ceiling(Edm.Decimal)
The ceiling
function rounds the input numeric parameter up to the nearest numeric value with no decimal component. The ceilingMethodCallExpr
syntax rule defines how the ceiling
function is invoked.
-Example 96: all orders with freight costs that round up to 32
+Example 97: all orders with freight costs that round up to 32
http://host/service/Orders?$filter=ceiling(Freight) eq 32
@@ -1697,7 +1707,7 @@ 5.1.1.9.2 floor
<
Edm.Decimal floor(Edm.Decimal)
The floor
function rounds the input numeric parameter down to the nearest numeric value with no decimal component. The floorMethodCallExpr
syntax rule defines how the floor
function is invoked.
-Example 97: all orders with freight costs that round down to 32
+Example 98: all orders with freight costs that round down to 32
http://host/service/Orders?$filter=floor(Freight) eq 32
@@ -1709,7 +1719,7 @@ 5.1.1.9.3 round
<
Edm.Decimal round(Edm.Decimal)
The round
function rounds the input numeric parameter to the nearest numeric value with no decimal component. The mid-point between two integers is rounded away from zero, i.e. 0.5 is rounded to 1 and -0.5 is rounded to -1. The roundMethodCallExpr
syntax rule defines how the round
function is invoked.
-Example 98: all orders with freight costs that round to 32
+Example 99: all orders with freight costs that round to 32
http://host/service/Orders?$filter=round(Freight) eq 32
@@ -1751,12 +1761,12 @@ 5.1.1.10.2 isof
The two parameter isof
function returns true if the object referred to by the expression is assignable to the type specified, according to the same rules, otherwise it returns false.
The isofExpr
syntax rule defines how the isof
function is invoked.
-Example 99: orders that are also BigOrders
+Example 100: orders that are also BigOrders
http://host/service/Orders?$filter=isof(NorthwindModel.BigOrder)
http://host/service/Orders?$filter=isof($it,NorthwindModel.BigOrder)
-Example 100: orders of a customer that is a VIPCustomer
+Example 101: orders of a customer that is a VIPCustomer
http://host/service/Orders?$filter=isof(Customer,NorthwindModel.VIPCustomer)
@@ -1803,7 +1813,7 @@ 5.1.1.12.1 case
Clients SHOULD ensure that the results in all pairs are compatible. If all results are of the same type, the type of the case
expression is of that type. If all results are of numeric type, then the type of the case
expression is a numeric type capable of representing any of these expressions according to standard type promotion rules.
Services MAY support case
expressions containing parameters of incompatible types, in which case the case expression is treated as Edm.Untyped
and its value has the type of the parameter expression selected by the case statement.
-Example 101: compute signum(X)
+Example 102: compute signum(X)
$compute=case(X gt 0:1,X lt 0:-1,true:0) as SignumX
@@ -1822,15 +1832,15 @@ 5.1.1.13.1 any
The any
operator applies a Boolean expression to each member of a collection and returns true if and only if the expression is true for any member of the collection, otherwise it returns false. This implies that the any
operator always returns false for an empty collection.
The any
operator can be used without an argument expression. This short form returns false if and only if the collection is empty.
-Example 102: all Orders
that have any Items
with a Quantity
greater than 100
+Example 103: all Orders
that have any Items
with a Quantity
greater than 100
http://host/service/Orders?$filter=Items/any(d:d/Quantity gt 100)
-Example 103: all customers having an order with a deviating shipping address. The Address
in the argument expression is evaluated in the scope of the Customers
collection.
+Example 104: all customers having an order with a deviating shipping address. The Address
in the argument expression is evaluated in the scope of the Customers
collection.
http://host/service/Customers?$filter=Orders/any(o:o/ShippingAddress ne Address)
-Example 104: all categories along with their products used in some order with a deviating unit price. The unprefixed UnitPrice
in the argument expression is evaluated in the scope of the expanded Products
.
+Example 105: all categories along with their products used in some order with a deviating unit price. The unprefixed UnitPrice
in the argument expression is evaluated in the scope of the expanded Products
.
http://host/service/Categories?$expand=Products(
$filter=OrderItems/any(oi:oi/UnitPrice ne UnitPrice))
@@ -1841,7 +1851,7 @@ 5.1.1.13.2 all
The all
operator applies a Boolean expression to each member of a collection and returns true if the expression is true for all members of the collection, otherwise it returns false. This implies that the all
operator always returns true for an empty collection.
The all
operator cannot be used without an argument expression.
-Example 105: all Orders
that have only Items
with a Quantity
greater than 100
+Example 106: all Orders
that have only Items
with a Quantity
greater than 100
http://host/service/Orders?$filter=Items/all(d:d/Quantity gt 100)
@@ -1854,7 +1864,7 @@ $filter
expressions. They are represented according to the primitiveLiteral
rule in OData-ABNF.
-Example 106: expressions using primitive literals
+Example 107: expressions using primitive literals
NullValue eq null
TrueValue eq true
FalseValue eq false
@@ -1885,11 +1895,11 @@ MUST be percent-encoded in URLs although some browsers will accept and pass them on unencoded.
-Example 107: collection of string literals
+Example 108: collection of string literals
http://host/service/ProductsByColors(colors=@c)?@c=["red","green"]
-Example 108: check whether a pair of properties has one of several possible pair values
+Example 109: check whether a pair of properties has one of several possible pair values
$filter=[FirstName,LastName] in [["John","Doe"],["Jane","Smith"]]
@@ -1907,15 +1917,15 @@ 5.1.1.14.4 $it
Note: property names and property paths in $filter
expressions nested within $expand
are evaluated in the context of the declared type of the expanded navigation property, so property names and property paths for the current instance of the collection identified by the resource path MUST be prefixed with $it/
.
The $it
literal can also be used as a path prefix to invoke a bound function overload on the current instance within an expression. Function names without a path prefix refer to an unbound function overload.
-Example 109: email addresses ending with .com
assuming EmailAddresses
is a collection of strings
+Example 110: email addresses ending with .com
assuming EmailAddresses
is a collection of strings
http://host/service/Customers(1)/EmailAddresses?$filter=endswith($it,'.com')
-Example 110: customers along with their orders that shipped to the same city as the customer’s address. The nested filter expression is evaluated in the context of Orders; $it
allows referring to values in the outer context of Customers. Note: the nested filter condition could equivalently be expressed as $it/Address/City eq
$this
/ShipTo/City
.
+Example 111: customers along with their orders that shipped to the same city as the customer’s address. The nested filter expression is evaluated in the context of Orders; $it
allows referring to values in the outer context of Customers. Note: the nested filter condition could equivalently be expressed as $it/Address/City eq
$this
/ShipTo/City
.
http://host/service/Customers?$expand=Orders($filter=$it/Address/City eq ShipTo/City)
-Example 111: products with at least 10 positive reviews. Model.PositiveReviews
is a function bound to Model.Product
returning a collection of reviews.
+Example 112: products with at least 10 positive reviews. Model.PositiveReviews
is a function bound to Model.Product
returning a collection of reviews.
http://host/service/Products?$filter=$it/Model.PositiveReviews()/$count ge 10
@@ -1924,16 +1934,16 @@ 5.1.1.14.5 $root
The $root
literal can be used in expressions to refer to resources of the same service.
-Example 112: all employees with the same last name as employee A1235
+Example 113: all employees with the same last name as employee A1235
http://host/service/Employees?$filter=LastName eq $root/Employees('A1245')/LastName
-Example 113: products ordered by a set of customers, where the set of customers is passed as a JSON array containing the resource paths from $root
to each customer
+Example 114: products ordered by a set of customers, where the set of customers is passed as a JSON array containing the resource paths from $root
to each customer
http://host/service/ProductsOrderedBy(Customers=@c)
?@c=[$root/Customers('ALFKI'),$root/Customers('BLAUS')]
-Example 114: function call returning the average rating of a given employee by their peers (employees in department D1)
+Example 115: function call returning the average rating of a given employee by their peers (employees in department D1)
http://host/service/Employees('A1245')/self.AvgRating(RatedBy=@peers)
?@peers=$root/Employees/$filter(Department eq 'D1')
@@ -1943,7 +1953,7 @@ 5.1.1.14.6 $this
The $this
literal can be used in $filter
and $orderby
expressions nested within $expand
and $select
for collection-valued properties and navigation properties. It refers to the current instance of the collection.
-Example 115: select only email addresses ending with .com
+Example 116: select only email addresses ending with .com
http://host/service/Customers?$select=EmailAddresses($filter=endswith($this,'.com'))
@@ -1956,7 +1966,7 @@
-Example 116: similar behavior whether HeadquarterAddress
is a nullable complex type or a nullable navigation property
+Example 117: similar behavior whether HeadquarterAddress
is a nullable complex type or a nullable navigation property
Companies(1)/HeadquarterAddress/Street
To access properties of derived types, the property name MUST be prefixed with the qualified name of the derived type on which the property is defined, followed by a forward slash (/
), see addressing derived types. If the current instance is not of the specified derived type, the path expression returns null
.
@@ -1970,11 +1980,11 @@ path expression leading to the annotated resource or property.
If an annotation is not applied to the resource or property, then its value, and the values of its components, are treated as null
.
-Example 117: Return Products that have prices in Euro
+Example 118: Return Products that have prices in Euro
http://host/service/Products?$filter=Price/@Measures.Currency eq 'EUR'
-Example 118: Return Employees that have any error messages in the Core.Messages
annotation
+Example 119: Return Employees that have any error messages in the Core.Messages
annotation
http://host/service/Employees?$filter=@Core.Messages/any(m:m/severity eq 'error')
Services MAY additionally support the use of the unqualified term name by defining one or more default namespaces through the Core.DefaultNamespace
annotation term defined in OData-VocCore. For more information on default namespaces, see Default Namespaces in OData-Protocol. This short notation however uses the same name pattern as parameter aliases. If a query option is specified as a parameter alias, then any occurrence of the parameter alias name in an expression MUST evaluate to the parameter alias value and MUST NOT evaluate to the annotation value of an identical unqualified term name.
@@ -2173,65 +2183,65 @@
-Example 119: expand a navigation property of an entity type
+Example 120: expand a navigation property of an entity type
http://host/service/Products?$expand=Category
-Example 120: expand a navigation property of a complex type
+Example 121: expand a navigation property of a complex type
http://host/service/Customers?$expand=Addresses/Country
A path MUST NOT appear in more than one expand item.
Query options can be applied to an expanded navigation property by appending a semicolon-separated list of query options, enclosed in parentheses, to the navigation property name. Allowed system query options are $compute
, $select
, $expand
, and $levels
for all navigation properties, plus $filter
, $orderby
, $skip
, $top
, $count
, and $search
for collection-valued navigation properties.
-Example 121: all categories and for each category all related products with a discontinued date equal to null
+Example 122: all categories and for each category all related products with a discontinued date equal to null
http://host/service/Categories?$expand=Products($filter=DiscontinuedDate eq null)
The $count
segment can be appended to a navigation property name or type-cast segment following a navigation property name to return just the count of the related entities. The $filter
and $search
system query options can be used to limit the number of related entities included in the count.
-Example 122: all categories and for each category the number of all related products
+Example 123: all categories and for each category the number of all related products
http://host/service/Categories?$expand=Products/$count
-Example 123: all categories and for each category the number of all related blue products
+Example 124: all categories and for each category the number of all related blue products
http://host/service/Categories?$expand=Products/$count($search=blue)
To retrieve entity references instead of the related entities, append /$ref
to the navigation property name or type-cast segment following a navigation property name. The system query options $filter
, $search
, $skip
, $top
, and $count
can be used to limit the number of expanded entity references.
-Example 124: all categories and for each category the references of all related products
+Example 125: all categories and for each category the references of all related products
http://host/service/Categories?$expand=Products/$ref
-Example 125: all categories and for each category the references of all related products of the derived type Sales.PremierProduct
+Example 126: all categories and for each category the references of all related products of the derived type Sales.PremierProduct
http://host/service/Categories?$expand=Products/Sales.PremierProduct/$ref
-Example 126: all categories and for each category the references of all related premier products with a current promotion equal to null
+Example 127: all categories and for each category the references of all related premier products with a current promotion equal to null
http://host/service/Categories
?$expand=Products/Sales.PremierProduct/$ref($filter=CurrentPromotion eq null)
-Example 127: all employees with their manager, manager’s manager, and manager’s manager’s manager
+Example 128: all employees with their manager, manager’s manager, and manager’s manager’s manager
http://host/service/Employees?$expand=ReportsTo($levels=3)
It is also possible to expand all declared and dynamic navigation properties using a star (*
). To retrieve references to all related entities use */$ref
, and to expand all related entities with a certain distance use the star operator with the $levels
option. The star operator can be combined with explicitly named navigation properties, which take precedence over the star operator.
The star operator does not implicitly include stream properties.
-Example 128: expand Supplier
and include references for all other related entities
+Example 129: expand Supplier
and include references for all other related entities
http://host/service/Categories?$expand=*/$ref,Supplier
-Example 129: expand all related entities and their related entities
+Example 130: expand all related entities and their related entities
http://host/service/Categories?$expand=*($levels=2)
Specifying a stream property includes the media stream inline according to the specified format.
-Example 130: include Employee’s Photo
stream property along with other properties of the customer
+Example 131: include Employee’s Photo
stream property along with other properties of the customer
http://host/service/Employees?$expand=Photo
Specifying $value
for a media entity includes the media entity’s stream value inline according to the specified format.
-Example 131: Include the Product’s media stream along with other properties of the product
+Example 132: Include the Product’s media stream along with other properties of the product
http://host/service/Products?$expand=$value
@@ -2257,12 +2267,12 @@
-Example 132: rating and release date of all products
+Example 133: rating and release date of all products
http://host/service/Products?$select=Rating,ReleaseDate
It is also possible to request all declared and dynamic structural properties using a star (*
).
-Example 133: all structural properties of all products
+Example 134: all structural properties of all products
http://host/service/Products?$select=*
If the select item is not defined for the type of the resource, and that type supports dynamic properties or instance annotations, then the property is treated as null for all instances on which it is not defined.
@@ -2270,21 +2280,21 @@ $expand
.
If the select item is a navigation property, then the corresponding navigation link is represented in the response. If the navigation property also appears in an $expand
query option, then it is additionally represented as inline content. This inline content can itself be restricted with a nested $select
query option, see section 5.1.2.
-Example 134: name and description of all products, plus name of expanded category
+Example 135: name and description of all products, plus name of expanded category
http://host/service/Products?$select=Name,Description
&$expand=Category($select=Name)
The select item MUST be prefixed with a qualified structured type name in order to select a property defined on a type derived from the type of the resource segment.
A select item that is a complex type or collection of complex type can be followed by a forward slash, an optional type-cast segment, and the name of a property of the complex type (and so on for nested complex types).
-Example 135: the AccountRepresentative
property of any supplier that is of the derived type Namespace.PreferredSupplier
, together with the Street
property of the complex property Address
, and the Location property of the derived complex type Namespace.AddressWithLocation
+Example 136: the AccountRepresentative
property of any supplier that is of the derived type Namespace.PreferredSupplier
, together with the Street
property of the complex property Address
, and the Location property of the derived complex type Namespace.AddressWithLocation
http://host/service/Suppliers
?$select=Namespace.PreferredSupplier/AccountRepresentative,
Address/Street,Address/Namespace.AddressWithLocation/Location
Query options can be applied to a select item that is a path to a single complex value or a collection of primitive or complex values by appending a semicolon-separated list of query options, enclosed in parentheses, to the select item. The allowed system query options depend on the type of the resource identified by the select item, see section System Query Options, with the exception of $expand
. The same property MUST NOT have select options specified in more than one place in a request and MUST NOT be specified in more than one expand.
-Example 136: select up to five addresses whose City
starts with an H
, sorted, and with the Country
expanded
+Example 137: select up to five addresses whose City
starts with an H
, sorted, and with the Country
expanded
http://host/service/Customers
?$select=Addresses($filter=startswith(City,'H');$top=5;
$orderby=Country/Name,City,Street)
@@ -2296,7 +2306,7 @@
-Example 137: the ID
property, the ActionName
action defined in Model
and all actions and functions defined in the Model2
for each product if those actions and functions can be bound to that product
+Example 138: the ID
property, the ActionName
action defined in Model
and all actions and functions defined in the Model2
for each product if those actions and functions can be bound to that product
http://host/service/Products?$select=ID,Model.ActionName,Model2.*
When multiple select item exist in a $select
clause, then the total set of properties, open properties, navigation properties, actions and functions to be returned is equal to the union of the set of those identified by each select item.
@@ -2328,7 +2338,7 @@ $filter
are applied to the same request, the results include only those items that match both criteria.
The OData-ABNF search
syntax rule defines the formal grammar of the $search
query option.
-Example 138: all products that are blue or green. It is up to the service to decide what makes a product blue or green.
+Example 139: all products that are blue or green. It is up to the service to decide what makes a product blue or green.
http://host/service/Products?$search=blue OR green
Clients should be aware that services MAY implement search based on a different syntax provided they advertise this with the annotation SearchRestrictions/SearchSyntax
defined in OData-VocCap. Services MAY treat keywords defined in the standard OData-ABNF $search
syntax as terms to be matched if they are listed in SearchRestrictions/UnsupportedExpressions
.
@@ -2364,7 +2374,7 @@ The OData-ABNF compute
syntax rule defines the formal grammar of the $compute
query option.
Computed properties SHOULD be included as dynamic properties in the result and MUST be included if $select
is specified with the computed property name, or star (*
).
-Example 139: compute total price for order items
+Example 140: compute total price for order items
http://host/service/Orders(10)/Items
?$select=Product/Description,Total
&$filter=Total gt 100
@@ -2391,7 +2401,7 @@ OData-ABNF.
Custom query options MUST NOT begin with a $
or @
character.
-Example 140: service-specific custom query option debug-mode
+Example 141: service-specific custom query option debug-mode
http://host/service/Products?debug-mode=true
@@ -2402,15 +2412,15 @@ OData-ABNF.
The semantics of parameter aliases are covered in OData-Protocol. The OData-ABNF rule aliasAndValue
defines the formal grammar for passing parameter alias values as query options.
-Example 141:
+Example 142:
http://host/service/Movies?$filter=contains(@word,Title)&@word='Black'
-Example 142:
+Example 143:
http://host/service/Movies?$filter=Title eq @title&@title='Wizard of Oz'
-Example 143: JSON array of strings as parameter alias value — note that [
, ]
, and "
need to be percent-encoded in real URLs, the clear-text representation used here is just for readability
+Example 144: JSON array of strings as parameter alias value — note that [
, ]
, and "
need to be percent-encoded in real URLs, the clear-text representation used here is just for readability
http://host/service/Products/Model.WithIngredients(Ingredients=@i)
?@i=["Carrots","Ginger","Oranges"]
diff --git a/docs/odata-url-conventions/odata-url-conventions.md b/docs/odata-url-conventions/odata-url-conventions.md
index 5a330a22..88d5c797 100644
--- a/docs/odata-url-conventions/odata-url-conventions.md
+++ b/docs/odata-url-conventions/odata-url-conventions.md
@@ -1525,13 +1525,27 @@ The value MUST be
* a JSON number for `$top` and `$skip`, and
* a JSON string without percent-encoding for all other query options.
+::: example
+Example 52: The same request as in [example 50](#postquery) can be sent with
+`application/json` encoding using the following payload:
+```json
+POST http://host/service/People/$query
+Content-Type: application/json
+
+{
+ "$filter": "LastName eq 'P&G'",
+ "$select": "FirstName,LastName"
+}
+```
+:::
+
Members of the JSON object also include parameters
if the resource path is a function invocation or function import. In this case
parameters MUST be represented like parameters in an action invocation [OData-JSON, section 18](#ODataJSON),
and in the resource path parentheses after the function name MUST be omitted.
::: example
-Example 52: An employee's top ten leave requests from now to the end of the year
+Example 53: An employee's top ten leave requests from now to the end of the year
pending their manager's approval. Compare this with [example 30](#funcexpr).
```json
POST http://host/service/Employees(23)/self.PendingLeaveRequests/$query
@@ -1796,49 +1810,49 @@ The following examples illustrate the use and semantics of each of the
logical operators.
::: example
-Example 53: all products with a `Name` equal to `Milk`
+Example 54: all products with a `Name` equal to `Milk`
```
http://host/service/Products?$filter=Name eq 'Milk'
```
:::
::: example
-Example 54: all products with a `Name` not equal to `Milk`
+Example 55: all products with a `Name` not equal to `Milk`
```
http://host/service/Products?$filter=Name ne 'Milk'
```
:::
::: example
-Example 55: all products with a `Name` greater than `Milk`:
+Example 56: all products with a `Name` greater than `Milk`:
```
http://host/service/Products?$filter=Name gt 'Milk'
```
:::
::: example
-Example 56: all products with a `Name` greater than or equal to `Milk`:
+Example 57: all products with a `Name` greater than or equal to `Milk`:
```
http://host/service/Products?$filter=Name ge 'Milk'
```
:::
::: example
-Example 57: all products with a `Name` less than `Milk`:
+Example 58: all products with a `Name` less than `Milk`:
```
http://host/service/Products?$filter=Name lt 'Milk'
```
:::
::: example
-Example 58: all products with a `Name` less than or equal to `Milk`:
+Example 59: all products with a `Name` less than or equal to `Milk`:
```
http://host/service/Products?$filter=Name le 'Milk'
```
:::
::: example
-Example 59: all products with a `Name` equal to `Milk` that also have a `Price`
+Example 60: all products with a `Name` equal to `Milk` that also have a `Price`
less than 2.55:
```
http://host/service/Products?$filter=Name eq 'Milk' and Price lt 2.55
@@ -1846,7 +1860,7 @@ http://host/service/Products?$filter=Name eq 'Milk' and Price lt 2.55
:::
::: example
-Example 60: all products that either have a `Name` equal to `Milk` or have a
+Example 61: all products that either have a `Name` equal to `Milk` or have a
`Price` less than 2.55:
```
http://host/service/Products?$filter=Name eq 'Milk' or Price lt 2.55
@@ -1854,21 +1868,21 @@ http://host/service/Products?$filter=Name eq 'Milk' or Price lt 2.55
:::
::: example
-Example 61: all products that do not have a `Name` that ends with `ilk`:
+Example 62: all products that do not have a `Name` that ends with `ilk`:
```
http://host/service/Products?$filter=not endswith(Name,'ilk')
```
:::
::: example
-Example 62: all products whose `style` value includes `Yellow`:
+Example 63: all products whose `style` value includes `Yellow`:
```
http://host/service/Products?$filter=style has Sales.Pattern'Yellow'
```
:::
::: example
-Example 63: all products whose `Name` is `Milk` or `Cheese`:
+Example 64: all products whose `Name` is `Milk` or `Cheese`:
```
http://host/service/Products?$filter=Name in ('Milk', 'Cheese')
```
@@ -1999,49 +2013,49 @@ The following examples illustrate the use and semantics of each of the
Arithmetic operators.
::: example
-Example 64: all products with a Price of 2.55:
+Example 65: all products with a Price of 2.55:
```
http://host/service/Products?$filter=Price add 2.45 eq 5.00
```
:::
::: example
-Example 65: all products with a Price of 2.55:
+Example 66: all products with a Price of 2.55:
```
http://host/service/Products?$filter=Price sub 0.55 eq 2.00
```
:::
::: example
-Example 66: all products with a Price of 2.55:
+Example 67: all products with a Price of 2.55:
```
http://host/service/Products?$filter=Price mul 2.0 eq 5.10
```
:::
::: example
-Example 67: all products with a Price of 2.55:
+Example 68: all products with a Price of 2.55:
```
http://host/service/Products?$filter=Price div 2.55 eq 1
```
:::
::: example
-Example 68: all products with an integer Rating value of 4 or 5:
+Example 69: all products with an integer Rating value of 4 or 5:
```
http://host/service/Products?$filter=Rating div 2 eq 2
```
:::
::: example
-Example 69: all products with an integer Rating value of 5:
+Example 70: all products with an integer Rating value of 5:
```
http://host/service/Products?$filter=Rating divby 2 eq 2.5
```
:::
::: example
-Example 70: all products with a Rating exactly divisible by 5:
+Example 71: all products with a Rating exactly divisible by 5:
```
http://host/service/Products?$filter=Rating mod 5 eq 0
```
@@ -2054,7 +2068,7 @@ evaluation order of an expression. The Grouping operator returns the
expression grouped inside the parenthesis.
::: example
-Example 71: all products because 9 mod 3 is 0
+Example 72: all products because 9 mod 3 is 0
```
http://host/service/Products?$filter=(4 add 5) mod (4 sub 1) eq 0
```
@@ -2104,7 +2118,7 @@ The `concatMethodCallExpr` syntax rule defines how the `concat` function
is invoked.
::: example
-Example 72: all customers from Berlin, Germany
+Example 73: all customers from Berlin, Germany
```
http://host/service/Customers?$filter=concat(concat(City,', '),Country) eq 'Berlin, Germany'
```
@@ -2135,7 +2149,7 @@ The `containsMethodCallExpr` syntax rule defines how the `contains`
function is invoked.
::: example
-Example 73: all customers with a `CompanyName` that contains `Alfreds`
+Example 74: all customers with a `CompanyName` that contains `Alfreds`
```
http://host/service/Customers?$filter=contains(CompanyName,'Alfreds')
```
@@ -2166,7 +2180,7 @@ The `endsWithMethodCallExpr` syntax rule defines how the `endswith`
function is invoked.
::: example
-Example 74: all customers with a `CompanyName` that ends with
+Example 75: all customers with a `CompanyName` that ends with
`Futterkiste`
```
http://host/service/Customers?$filter=endswith(CompanyName,'Futterkiste')
@@ -2198,7 +2212,7 @@ The `indexOfMethodCallExpr` syntax rule defines how the `indexof`
function is invoked.
::: example
-Example 75: all customers with a `CompanyName` containing `lfreds`
+Example 76: all customers with a `CompanyName` containing `lfreds`
starting at the second character
```
http://host/service/Customers?$filter=indexof(CompanyName,'lfreds') eq 1
@@ -2224,7 +2238,7 @@ The `lengthMethodCallExpr` syntax rule defines how the `length` function
is invoked.
::: example
-Example 76: all customers with a `CompanyName` that is 19 characters
+Example 77: all customers with a `CompanyName` that is 19 characters
long
```
http://host/service/Customers?$filter=length(CompanyName) eq 19
@@ -2256,7 +2270,7 @@ The `startsWithMethodCallExpr` syntax rule defines how the `startswith`
function is invoked.
::: example
-Example 77: all customers with a `CompanyName` that starts with `Alfr`
+Example 78: all customers with a `CompanyName` that starts with `Alfr`
```
http://host/service/Customers?$filter=startswith(CompanyName,'Alfr')
```
@@ -2310,7 +2324,7 @@ The `substringMethodCallExpr` syntax rule defines how the `substring`
function is invoked.
::: example
-Example 78: all customers with a `CompanyName` of `lfreds Futterkiste`
+Example 79: all customers with a `CompanyName` of `lfreds Futterkiste`
once the first character has been removed
```
http://host/service/Customers?$filter=substring(CompanyName,1) eq 'lfreds Futterkiste'
@@ -2318,7 +2332,7 @@ http://host/service/Customers?$filter=substring(CompanyName,1) eq 'lfreds Futter
:::
::: example
-Example 79: all customers with a `CompanyName` that has `lf` as the
+Example 80: all customers with a `CompanyName` that has `lf` as the
second and third characters, e.g, `Alfreds Futterkiste`
```
http://host/service/Customers?$filter=substring(CompanyName,1,2) eq 'lf'
@@ -2341,7 +2355,7 @@ zero or more items. The `hasSubsetMethodCallExpr` syntax rule defines
how the `hassubset` function is invoked.
::: example
-Example 80: `hassubset` expressions that return true
+Example 81: `hassubset` expressions that return true
```
hassubset([4,1,3],[4,1,3])
```
@@ -2364,7 +2378,7 @@ hassubset([4,1,3,1],[1,1])
:::
::: example
-Example 81: `hassubset` expression that returns false: 1 appears only
+Example 82: `hassubset` expression that returns false: 1 appears only
once in the left operand
```
hassubset([1,2],[1,1,2])
@@ -2385,7 +2399,7 @@ items. The `hasSubsequenceMethodCallExpr` syntax rule defines how the
`hassubsequence` function is invoked.
::: example
-Example 82: `hassubsequence` expressions that return true
+Example 83: `hassubsequence` expressions that return true
```
hassubsequence([4,1,3],[4,1,3])
```
@@ -2404,7 +2418,7 @@ hassubsequence([4,1,3,1],[1,1])
:::
::: example
-Example 83: `hassubsequence` expressions that return false
+Example 84: `hassubsequence` expressions that return false
```
hassubsequence([4,1,3],[1,3,4])
```
@@ -2438,7 +2452,7 @@ If the optional third parameter is provided, it MUST evaluate to a string
consisting of ECMAScript regular expression flags to modify the match.
::: example
-Example 84: all customers with a `CompanyName` that match the
+Example 85: all customers with a `CompanyName` that match the
(percent-encoded) regular expression `^A.*e$`
```
http://host/service/Customers?$filter=matchespattern(CompanyName,'%5EA.*e$')
@@ -2446,7 +2460,7 @@ http://host/service/Customers?$filter=matchespattern(CompanyName,'%5EA.*e$')
:::
::: example
-Example 85: all customers with a `FormattedAddress` that contains a line ending with `berg` or ends with `berg`
+Example 86: all customers with a `FormattedAddress` that contains a line ending with `berg` or ends with `berg`
```
http://host/service/Customers?$filter=matchespattern(FormattedAddress,'berg$','m')
```
@@ -2466,7 +2480,7 @@ The `toLowerMethodCallExpr` syntax rule defines how the `tolower`
function is invoked.
::: example
-Example 86: all customers with a `CompanyName` that equals
+Example 87: all customers with a `CompanyName` that equals
`alfreds futterkiste` once any uppercase characters have been
converted to lowercase
```
@@ -2488,7 +2502,7 @@ The `toUpperMethodCallExpr` syntax rule defines how the `toupper`
function is invoked.
::: example
-Example 87: all customers with a `CompanyName` that equals
+Example 88: all customers with a `CompanyName` that equals
`ALFREDS FUTTERKISTE` once any lowercase characters have been
converted to uppercase
```
@@ -2510,7 +2524,7 @@ removed. The `trimMethodCallExpr` syntax rule defines how the `trim`
function is invoked.
::: example
-Example 88: all customers with a `CompanyName` without leading or
+Example 89: all customers with a `CompanyName` without leading or
trailing whitespace characters
```
http://host/service/Customers?$filter=trim(CompanyName) eq CompanyName
@@ -2552,7 +2566,7 @@ UTC) MUST fail evaluation of the `day` function for literal
normalized values.
::: example
-Example 89: all employees born on the 8th day of a month
+Example 90: all employees born on the 8th day of a month
```
http://host/service/Employees?$filter=day(BirthDate) eq 8
```
@@ -2574,7 +2588,7 @@ non-negative decimal value less than 1. The
`fractionalseconds` function is invoked.
::: example
-Example 90: all employees born less than 100 milliseconds after a full
+Example 91: all employees born less than 100 milliseconds after a full
second of any minute of any hour on any day
```
http://host/service/Employees?$filter=[fractionalseconds(BirthDate) lt 0.1
@@ -2602,7 +2616,7 @@ UTC) MUST fail evaluation of the `hour` function for literal
normalized values.
::: example
-Example 91: all employees born in hour 4, between 04:00 (inclusive) and
+Example 92: all employees born in hour 4, between 04:00 (inclusive) and
05:00 (exclusive)
```
http://host/service/Employees?$filter=hour(BirthDate) eq 4
@@ -2646,7 +2660,7 @@ zone of the `DateTimeOffset` parameter value. The `minuteMethodCallExpr`
syntax rule defines how the `minute` function is invoked.
::: example
-Example 92: all employees born in minute 40 of any hour on any day
+Example 93: all employees born in minute 40 of any hour on any day
```
http://host/service/Employees?$filter=minute(BirthDate) eq 40
```
@@ -2673,7 +2687,7 @@ UTC) MUST fail evaluation of the `month` function for literal
normalized values.
::: example
-Example 93: all employees born in May
+Example 94: all employees born in May
```
http://host/service/Employees?$filter=month(BirthDate) eq 5
```
@@ -2712,7 +2726,7 @@ of the `DateTimeOffset` or `TimeOfDay` parameter value. The
invoked.
::: example
-Example 94: all employees born in second 40 of any minute of any hour on
+Example 95: all employees born in second 40 of any minute of any hour on
any day
```
http://host/service/Employees?$filter=second(BirthDate) eq 40
@@ -2781,7 +2795,7 @@ UTC) MUST fail evaluation of the `year` function for literal
normalized values.
::: example
-Example 95: all employees born in 1971
+Example 96: all employees born in 1971
```
http://host/service/Employees?$filter=year(BirthDate) eq 1971
```
@@ -2804,7 +2818,7 @@ nearest numeric value with no decimal component. The
is invoked.
::: example
-Example 96: all orders with freight costs that round up to 32
+Example 97: all orders with freight costs that round up to 32
```
http://host/service/Orders?$filter=ceiling(Freight) eq 32
```
@@ -2825,7 +2839,7 @@ nearest numeric value with no decimal component. The
invoked.
::: example
-Example 97: all orders with freight costs that round down to 32
+Example 98: all orders with freight costs that round down to 32
```
http://host/service/Orders?$filter=floor(Freight) eq 32
```
@@ -2847,7 +2861,7 @@ rounded to -1. The `roundMethodCallExpr` syntax rule defines how the
`round` function is invoked.
::: example
-Example 98: all orders with freight costs that round to 32
+Example 99: all orders with freight costs that round to 32
```
http://host/service/Orders?$filter=round(Freight) eq 32
```
@@ -2916,7 +2930,7 @@ same rules, otherwise it returns false.
The `isofExpr` syntax rule defines how the `isof` function is invoked.
::: example
-Example 99: orders that are also `BigOrders`
+Example 100: orders that are also `BigOrders`
```
http://host/service/Orders?$filter=isof(NorthwindModel.BigOrder)
```
@@ -2927,7 +2941,7 @@ http://host/service/Orders?$filter=isof($it,NorthwindModel.BigOrder)
:::
::: example
-Example 100: orders of a customer that is a `VIPCustomer`
+Example 101: orders of a customer that is a `VIPCustomer`
```
http://host/service/Orders?$filter=isof(Customer,NorthwindModel.VIPCustomer)
```
@@ -3011,7 +3025,7 @@ incompatible types, in which case the case expression is treated as
selected by the case statement.
::: example
-Example 101: compute signum(X)
+Example 102: compute signum(X)
```
$compute=case(X gt 0:1,X lt 0:-1,true:0) as SignumX
```
@@ -3053,7 +3067,7 @@ The `any` operator can be used without an argument expression. This
short form returns false if and only if the collection is empty.
::: example
-Example 102: all `Orders` that have any `Items` with a `Quantity` greater
+Example 103: all `Orders` that have any `Items` with a `Quantity` greater
than `100`
```
http://host/service/Orders?$filter=Items/any(d:d/Quantity gt 100)
@@ -3061,7 +3075,7 @@ http://host/service/Orders?$filter=Items/any(d:d/Quantity gt 100)
:::
::: example
-Example 103: all customers having an order with a deviating shipping
+Example 104: all customers having an order with a deviating shipping
address. The `Address` in the argument expression is evaluated in the
scope of the `Customers` collection.
```
@@ -3070,7 +3084,7 @@ http://host/service/Customers?$filter=Orders/any(o:o/ShippingAddress ne Address)
:::
::: example
-Example 104: all categories along with their products used in some order
+Example 105: all categories along with their products used in some order
with a deviating unit price. The unprefixed `UnitPrice` in the argument
expression is evaluated in the scope of the expanded `Products`.
```
@@ -3089,7 +3103,7 @@ operator always returns true for an empty collection.
The `all` operator cannot be used without an argument expression.
::: example
-Example 105: all `Orders` that have only `Items` with a `Quantity`
+Example 106: all `Orders` that have only `Items` with a `Quantity`
greater than `100`
```
http://host/service/Orders?$filter=Items/all(d:d/Quantity gt 100)
@@ -3106,7 +3120,7 @@ values, and in the query part, for example, as operands in
according to the `primitiveLiteral` rule in [OData-ABNF](#ODataABNF).
::: example
-Example 106: expressions using primitive literals
+Example 107: expressions using primitive literals
```
NullValue eq null
```
@@ -3211,14 +3225,14 @@ percent-encoded in URLs although some browsers will accept and pass them
on unencoded.
::: example
-Example 107: collection of string literals
+Example 108: collection of string literals
```
http://host/service/ProductsByColors(colors=@c)?@c=["red","green"]
```
:::
::: example
-Example 108: check whether a pair of properties has one of several
+Example 109: check whether a pair of properties has one of several
possible pair values
```
$filter=[FirstName,LastName] in [["John","Doe"],["Jane","Smith"]]
@@ -3264,7 +3278,7 @@ function overload on the current instance within an expression. Function
names without a path prefix refer to an unbound function overload.
::: example
-Example 109: email addresses ending with `.com` assuming
+Example 110: email addresses ending with `.com` assuming
`EmailAddresses` is a collection of strings
```
http://host/service/Customers(1)/EmailAddresses?$filter=endswith($it,'.com')
@@ -3272,7 +3286,7 @@ http://host/service/Customers(1)/EmailAddresses?$filter=endswith($it,'.com')
:::
::: example
-Example 110: customers along with their orders that shipped to the same
+Example 111: customers along with their orders that shipped to the same
city as the customer's address. The nested filter expression is
evaluated in the context of Orders; `$it` allows referring to values in
the outer context of Customers.
@@ -3283,7 +3297,7 @@ http://host/service/Customers?$expand=Orders($filter=$it/Address/City eq ShipTo/
:::
::: example
-Example 111: products with at least 10 positive reviews.
+Example 112: products with at least 10 positive reviews.
`Model.PositiveReviews` is a function bound to `Model.Product` returning
a collection of reviews.
```
@@ -3297,14 +3311,14 @@ The `$root` literal can be used in expressions to refer to resources of
the same service.
::: example
-Example 112: all employees with the same last name as employee `A1235`
+Example 113: all employees with the same last name as employee `A1235`
```
http://host/service/Employees?$filter=LastName eq $root/Employees('A1245')/LastName
```
:::
::: example
-Example 113: products ordered by a set of customers, where the set of
+Example 114: products ordered by a set of customers, where the set of
customers is passed as a JSON array containing the resource paths from
`$root` to each customer
```
@@ -3314,7 +3328,7 @@ http://host/service/ProductsOrderedBy(Customers=@c)
:::
::: example
-Example 114: function call returning the average rating of a given employee by their peers (employees in department D1)
+Example 115: function call returning the average rating of a given employee by their peers (employees in department D1)
```
http://host/service/Employees('A1245')/self.AvgRating(RatedBy=@peers)
?@peers=$root/Employees/$filter(Department eq 'D1')
@@ -3331,7 +3345,7 @@ and navigation properties. It refers to the current instance of the
collection.
::: example
-Example 115: select only email addresses ending with `.com`
+Example 116: select only email addresses ending with `.com`
```
http://host/service/Customers?$select=EmailAddresses($filter=endswith($this,'.com'))
```
@@ -3358,7 +3372,7 @@ target cardinality 0..1), its value, and the values of its components,
are treated as `null`.
::: example
-Example 116: similar behavior whether `HeadquarterAddress` is a nullable
+Example 117: similar behavior whether `HeadquarterAddress` is a nullable
complex type or a nullable navigation property
```
Companies(1)/HeadquarterAddress/Street
@@ -3399,14 +3413,14 @@ If an annotation is not applied to the resource or property, then its
value, and the values of its components, are treated as `null`.
::: example
-Example 117: Return Products that have prices in Euro
+Example 118: Return Products that have prices in Euro
```
http://host/service/Products?$filter=Price/@Measures.Currency eq 'EUR'
```
:::
::: example
-Example 118: Return Employees that have any error messages in the
+Example 119: Return Employees that have any error messages in the
[`Core.Messages`](https://github.com/oasis-tcs/odata-vocabularies/blob/main/vocabularies/Org.OData.Core.V1.md#Messages)
annotation
```
@@ -3541,14 +3555,14 @@ segment does not specify a declared property, then the expanded property
appears only for those instances on which it has a value.
::: example
-Example 119: expand a navigation property of an entity type
+Example 120: expand a navigation property of an entity type
```
http://host/service/Products?$expand=Category
```
:::
::: example
-Example 120: expand a navigation property of a complex type
+Example 121: expand a navigation property of a complex type
```
http://host/service/Customers?$expand=Addresses/Country
```
@@ -3572,7 +3586,7 @@ Allowed system query options are
for collection-valued navigation properties.
::: example
-Example 121: all categories and for each category all related products
+Example 122: all categories and for each category all related products
with a discontinued date equal to `null`
```
http://host/service/Categories?$expand=Products($filter=DiscontinuedDate eq null)
@@ -3586,7 +3600,7 @@ property name to return just the count of the related entities. The
number of related entities included in the count.
::: example
-Example 122: all categories and for each category the number of all
+Example 123: all categories and for each category the number of all
related products
```
http://host/service/Categories?$expand=Products/$count
@@ -3594,7 +3608,7 @@ http://host/service/Categories?$expand=Products/$count
:::
::: example
-Example 123: all categories and for each category the number of all
+Example 124: all categories and for each category the number of all
related blue products
```
http://host/service/Categories?$expand=Products/$count($search=blue)
@@ -3611,7 +3625,7 @@ The system query options [`$filter`](#SystemQueryOptionfilter),
expanded entity references.
::: example
-Example 124: all categories and for each category the references of all
+Example 125: all categories and for each category the references of all
related products
```
http://host/service/Categories?$expand=Products/$ref
@@ -3619,7 +3633,7 @@ http://host/service/Categories?$expand=Products/$ref
:::
::: example
-Example 125: all categories and for each category the references of all
+Example 126: all categories and for each category the references of all
related products of the derived type `Sales.PremierProduct`
```
http://host/service/Categories?$expand=Products/Sales.PremierProduct/$ref
@@ -3627,7 +3641,7 @@ http://host/service/Categories?$expand=Products/Sales.PremierProduct/$ref
:::
::: example
-Example 126: all categories and for each category the references of all
+Example 127: all categories and for each category the references of all
related premier products with a current promotion equal to `null`
```
http://host/service/Categories
@@ -3644,7 +3658,7 @@ A `$levels` option with a value of 1 specifies a single expand with no
recursion.
::: example
-Example 127: all employees with their manager, manager's manager, and
+Example 128: all employees with their manager, manager's manager, and
manager's manager's manager
```
http://host/service/Employees?$expand=ReportsTo($levels=3)
@@ -3661,7 +3675,7 @@ which take precedence over the star operator.
The star operator does not implicitly include stream properties.
::: example
-Example 128: expand `Supplier` and include references for all other
+Example 129: expand `Supplier` and include references for all other
related entities
```
http://host/service/Categories?$expand=*/$ref,Supplier
@@ -3669,7 +3683,7 @@ http://host/service/Categories?$expand=*/$ref,Supplier
:::
::: example
-Example 129: expand all related entities and their related entities
+Example 130: expand all related entities and their related entities
```
http://host/service/Categories?$expand=*($levels=2)
```
@@ -3679,7 +3693,7 @@ Specifying a stream property includes the media stream inline according
to the specified format.
::: example
-Example 130: include Employee's `Photo` stream property along with other
+Example 131: include Employee's `Photo` stream property along with other
properties of the customer
```
http://host/service/Employees?$expand=Photo
@@ -3690,7 +3704,7 @@ Specifying `$value` for a media entity includes the media entity's
stream value inline according to the specified format.
::: example
-Example 131: Include the Product's media stream along with other
+Example 132: Include the Product's media stream along with other
properties of the product
```
http://host/service/Products?$expand=$value
@@ -3749,7 +3763,7 @@ The simplest form of a select item explicitly requests a property defined on the
type of the resources identified by the resource path section of the URL.
::: example
-Example 132: rating and release date of all products
+Example 133: rating and release date of all products
```
http://host/service/Products?$select=Rating,ReleaseDate
```
@@ -3759,7 +3773,7 @@ It is also possible to request all declared and dynamic structural
properties using a star (`*`).
::: example
-Example 133: all structural properties of all products
+Example 134: all structural properties of all products
```
http://host/service/Products?$select=*
```
@@ -3787,7 +3801,7 @@ inline content can itself be restricted with a nested `$select` query
option, see [section 5.1.2](#SystemQueryOptionfilter).
::: example
-Example 134: name and description of all products, plus name of expanded
+Example 135: name and description of all products, plus name of expanded
category
```
http://host/service/Products?$select=Name,Description
@@ -3804,7 +3818,7 @@ be followed by a forward slash, an optional [type-cast segment](#AddressingDeriv
complex type (and so on for nested complex types).
::: example
-Example 135: the `AccountRepresentative` property of any supplier that
+Example 136: the `AccountRepresentative` property of any supplier that
is of the derived type `Namespace.PreferredSupplier`, together with the
`Street` property of the complex property
`Address`, and the Location property of the derived complex type `Namespace.AddressWithLocation`
@@ -3826,7 +3840,7 @@ select options specified in more than one place in a request and MUST
NOT be specified in more than one expand.
::: example
-Example 136: select up to five addresses whose `City` starts with an
+Example 137: select up to five addresses whose `City` starts with an
`H`, sorted, and with the `Country` expanded
```
http://host/service/Customers
@@ -3863,7 +3877,7 @@ qualified name and that operation cannot be bound to the entities
requested, the service MUST ignore the select item.
::: example
-Example 137: the `ID` property, the `ActionName` action defined in
+Example 138: the `ID` property, the `ActionName` action defined in
`Model` and all actions and functions defined in the `Model2` for each
product if those actions and functions can be bound to that product
```
@@ -3929,7 +3943,7 @@ The [OData-ABNF](#ODataABNF) `search` syntax rule defines the formal
grammar of the `$search` query option.
::: example
-Example 138: all products that are blue or green. It is up to the
+Example 139: all products that are blue or green. It is up to the
service to decide what makes a product blue or green.
```
http://host/service/Products?$search=blue OR green
@@ -4024,7 +4038,7 @@ result and MUST be included if `$select` is specified with the computed
property name, or star (`*`).
::: example
-Example 139: compute total price for order items
+Example 140: compute total price for order items
```
http://host/service/Orders(10)/Items
?$select=Product/Description,Total
@@ -4068,7 +4082,7 @@ custom query option is any query option of the form shown by the rule
Custom query options MUST NOT begin with a `$` or `@` character.
::: example
-Example 140: service-specific custom query option `debug-mode`
+Example 141: service-specific custom query option `debug-mode`
```
http://host/service/Products?debug-mode=true
```
@@ -4090,21 +4104,21 @@ The semantics of parameter aliases are covered in
values as query options.
::: example
-Example 141:
+Example 142:
```
http://host/service/Movies?$filter=contains(@word,Title)&@word='Black'
```
:::
::: example
-Example 142:
+Example 143:
```
http://host/service/Movies?$filter=Title eq @title&@title='Wizard of Oz'
```
:::
::: example
-Example 143: JSON array of strings as parameter alias value --- note that
+Example 144: JSON array of strings as parameter alias value --- note that
`[`, `]`, and `"` need to be percent-encoded in real URLs, the
clear-text representation used here is just for readability
```
diff --git a/odata-url-conventions/4 Resource Path.md b/odata-url-conventions/4 Resource Path.md
index 885c7985..482ffea2 100644
--- a/odata-url-conventions/4 Resource Path.md
+++ b/odata-url-conventions/4 Resource Path.md
@@ -1070,6 +1070,20 @@ The value MUST be
* a JSON number for `$top` and `$skip`, and
* a JSON string without percent-encoding for all other query options.
+::: example
+Example ##ex: The same request as in [example ##postquery] can be sent with
+`application/json` encoding using the following payload:
+```json
+POST http://host/service/People/$query
+Content-Type: application/json
+
+{
+ "$filter": "LastName eq 'P&G'",
+ "$select": "FirstName,LastName"
+}
+```
+:::
+
Members of the JSON object also include parameters
if the resource path is a function invocation or function import. In this case
parameters MUST be represented like parameters in an action invocation [OData-JSON, section 18](#ODataJSON),