SortProperty Class
SortProperty Class
Enables sorting the FindResults when specified with the FindFilter object. Sorting is performed based on the input property names and the sort direction (ascending or descending).
Public Class SortProperty Inherits System.Object
[C#]
public class SortProperty : System.Object
Public Properties
Name | Description |
---|---|
Direction | Determines the direction (Ascending or Descending) of sorting for the property specified by the PropertyName property. |
PropertyName | Name of the entity property name used to sort the find results. |
Remarks
When sort property names are specified with no sort direction (ascending or descending), ascending sort direction is assumed.
The sort priority for the properties is given in the same order as they are specified.
The data type of the PropertyName property affects how the results are sorted. Sorting using a String property sorts the results alphabetically, while sorting using a Long or Double property sorts the results numerically.
When using SortProperties in a FindNearby query, all entities within the radius you specify in FindNearbySpecification.Distance are considered before the results are sorted. The FindResults.NumberFound property indicates the total number of results found within the search radius (to a maximum of 500). If NumberFound is higher than Options.Range.Count and SortProperties is specified, entities extremely close to FindNearbySpecification.LatLong may not be included in FindResults.
Example
[Visual Basic]
Dim findServiceSoap As FindServiceSoap = New FindServiceSoap
findServiceSoap.Credentials = _
New NetworkCredential(myMapPointUserId, mySecurePassword)
Dim strs As String() = New String() {"Manager"}
Dim sortPropertys As SortProperty() = New SortProperty() {New SortProperty}
sortPropertys(0).PropertyName = "Manager"
sortPropertys(0).Direction = SortDirection.Descending
Dim findNearbySpecification As FindNearbySpecification = New FindNearbySpecification
findNearbySpecification.DataSourceName = "MapPoint.FourthCoffeeSample"
findNearbySpecification.Distance = 1.0
findNearbySpecification.LatLong = New LatLong
findNearbySpecification.LatLong.Latitude = 47.6
findNearbySpecification.LatLong.Longitude = -122.33
findNearbySpecification.Filter = New FindFilter
findNearbySpecification.Filter.EntityTypeName = "FourthCoffeeShops"
findNearbySpecification.Filter.PropertyNames = strs
findNearbySpecification.Filter.SortProperties = sortPropertys
Dim findResults As FindResults = findServiceSoap.FindNearby(findNearbySpecification)
[C#]
FindServiceSoap findService = new FindServiceSoap();
findService.Credentials =
new System.Net.NetworkCredential(myMapPointUserId, mySecurePassword);
string[] returnProperties = new string[1];
returnProperties[0] = "Manager";
//Specify what properties to be used to sort the found results
SortProperty[] sortproperties = new SortProperty[1];
sortproperties[0] = new SortProperty();
//Assign the property name to be sorted on
sortproperties[0].PropertyName = "Manager";
//Specify the sort direction: Ascending or Descending
sortproperties[0].Direction = SortDirection.Descending;
FindNearbySpecification findNearbySpec = new FindNearbySpecification();
findNearbySpec.DataSourceName = "MapPoint.FourthCoffeeSample";
findNearbySpec.Distance = 1;
findNearbySpec.LatLong = new LatLong();
findNearbySpec.LatLong.Latitude = 47.6;
findNearbySpec.LatLong.Longitude = -122.33;
findNearbySpec.Filter = new FindFilter();
findNearbySpec.Filter.EntityTypeName = "FourthCoffeeShops";
findNearbySpec.Filter.PropertyNames = returnProperties;
//Assign the sort property list to the
//find nearby specification filter object
findNearbySpec.Filter.SortProperties = sortproperties;
FindResults foundResults;
foundResults = findService.FindNearby(findNearbySpec);
See Also
SortDirection Enumeration | FindFilter Class