Feature service QueryRelatedObjects method

Queries and returns the related features/objects that satisfy the criteria.

ServiceData QueryRelatedObjects(int SourceLayerOrTableID, int[] ObjectIDsInSource, int RelationshipID, string TargetDefinitionExpression, string TargetTableProps, bool GroupBySourceOIDs, SpatialReference OutSR, TimeReference OutTR, ServiceDataOptions ServiceDataOptions, string VersionName, double MaximumAllowableOffset)




The identifier of the source layer or table.


The IDs of the features or objects for which related objects are being searched..


The target layer/table ID.


Criteria to select features or objects from related selection.


Comma separated names of the properties to be returned in the result.


If true, the result has related objects sorted by source objects' IDs, else they are just an array of objects.


The spatial reference in which to return the results.


The time reference in which to return the results.


Specifies the format and transport types.


Geodatabase version to query. This parameter applies only to feature services that expose geodatabases. If not specified, queries are made against the published map's version.


Specifies the maximum allowable offset to be used for generalizing geometries returned by the query operation. The MaximumAllowableOffset is in the units of the OutSR. If the OutSR is not specified, then MaximumAllowableOffset is assumed to be in the unit of the spatial reference of the map.

Return Value

Returns an object of ServiceData type. If GroupBySourceOIDs is false, the returned object contains an array of DataObject elements. If GroupBySourceOIDs is true, it contains an array of DataObjectGroup elements, which has related features or objects grouped by source features' ObjectIDs.


Only the fields that are expressed in TargetTableProps are returned. Setting GroupBySourceOIDs to true returns the results group, but can take longer to process. If you do not need to set the spatial reference or the time reference set the parameters to null.