Projection

Projection allows a REST API client to control:

This is accomplished using the $select and $expand query options.
- By default, no relations are expanded.
- They can be combined to fine-tune which fields and related entities are returned.


Examples

1. Return all properties of a single Service Request

GET http://myserver:5181/odata/ServiceRequests(3101097999)

2. Return only specific fields (Description, Information)

GET http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Description,Information

5. Expand Workorders for the first 10 Service Requests

GET http://myserver:5181/odata/ServiceRequests?$top=10&$select=Description,Information&$expand=Workorders($select=ID,Description)

6. Expand a Caller (1:1 or N:1 relation)

GET http://myserver:5181/odata/ServiceRequests(3101097999)?$expand=Caller

7. Expand Caller and its Organization (selected fields)

GET http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Description,Information&$expand=Caller($expand=Organization($select=Name))

If the $select clause is omitted for Organization, all its fields will be returned.


Invalid Usage

Navigation properties must not be included in $select.
The following are invalid:

http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Uid,Description,Information,Workorders
http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Uid,Description,Information,Caller

Correct usage with $expand:

http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Uid,Description,Information&$expand=Workorders
http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Uid,Description,Information&$expand=Caller

Important Note on $select with $expand

When expanding a navigation property while using $select, the Uid key property must be included.

  • Invalid:
http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Description,Information&$expand=Caller
  • Valid:
http://myserver:5181/odata/ServiceRequests(3101097999)?$select=Uid,Description,Information&$expand=Caller

References

Back to top