You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The $compute query option is pretty awesome in that it allows arbitrary projection and creation of computed properties based on other existing properties.
However, using it is a bit cumbersome IMHO: you not only have to create the property in the $compute query option, but you also have to explicitly select it in $select. This feels really counterintuitive to me:
GET /api/products/1?$compute=Price mult Quantity as TotalPrice
The query above creates the TotalPrice computed property, but it is otherwise completely ignored. To actually add the property to the result set, you have to explicitly include it with either:
GET /api/products/1?$compute=Price mult Quantity as TotalPrice&$select=Name, SomeOtherProductProperty, Quantity, Price, TotalPrice
Or with a "include all" select:
GET /api/products/1?$compute=Price mult Quantity as TotalPrice&$select=*
Wouldn't it make a lot more sense and be significantly more intuitive to just add the computed properties in the resulting payload by default?
If the $select query option is not specified, the service returns the full set of properties or a default set of properties. The default set of properties MUST include all key properties. Services may change the default set of properties returned. This includes returning new properties by default and omitting properties previously returned by default. Clients that rely on specific properties in the response MUST use $select with the required properties or with *.
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 (*).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The
$compute
query option is pretty awesome in that it allows arbitrary projection and creation of computed properties based on other existing properties.However, using it is a bit cumbersome IMHO: you not only have to create the property in the
$compute
query option, but you also have to explicitly select it in$select
. This feels really counterintuitive to me:The query above creates the
TotalPrice
computed property, but it is otherwise completely ignored. To actually add the property to the result set, you have to explicitly include it with either:Or with a "include all" select:
Wouldn't it make a lot more sense and be significantly more intuitive to just add the computed properties in the resulting payload by default?
Relevant sections in the spec:
Beta Was this translation helpful? Give feedback.
All reactions