order By
See orderBy(QueryValue, SortOrder).
Return
(see linked method).
Parameters
value
Value parameter.
Add to {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#sortItems DataQuery.sortItems} a value for result ordering.
- Example using proxy classes:
open fun orderByExample(): kotlin.Unit { // Find the 3 artists born nearest to Avila, Spain. val service = this.service; val avila = GeographyPoint.withLatitudeLongitude(40.6567, -4.6812); val query = DataQuery().top(3) .orderBy(Artist.placeOfBirth.geoDistance(avila)); val artists = service.getArtists(query); this.showArtists(artists); }
- Example using dynamic API:
open fun orderByExample(): kotlin.Unit { // Find the 3 artists born nearest to Avila, Spain. val service = this.service; val artistsEntitySet = service.getEntitySet("Artists"); val artistEntityType = artistsEntitySet.entityType; val placeOfBirthProperty = artistEntityType.getProperty("placeOfBirth"); val avila = GeographyPoint.withLatitudeLongitude(40.6567, -4.6812); val query = DataQuery().top(3).from(artistsEntitySet) .orderBy(placeOfBirthProperty.geoDistance(avila)); val artists = service.executeQuery(query).getEntityList(); this.showArtists(artists); }
Return
This query.
Parameters
value
Value for ordering.
order
The sort order (defaults to ascending).