Map Service QueryRelatedRecords method

Queries and returns a related-record set of features or rows that are related to the specified features or rows for the specified layer or table id.

 

QueryRelatedRecords(string MapName, int SourceTableID, FIDSet SourceFIDSet, RelateDescription RelateDescription)

 

Parameter

Description

MapName

The name of the map (data frame) that contains the layer associated with the SourceTableID parameter.

SourceTableID

The layer or standalone table id of the source layer or table.

SourceFIDSet

An FIDSet that contains an array of integers. Each integer represents a unique identifier for each feature or row (ObjectID) in the source layer or table whose related rows/features will be queried.

RelateDescription

Describes the related table for which the related records are being queried and how result records are formatted.

 

Return Value

 

A QueryResult object is returned. When "esriRelateResultRelatedRecordSetAsObject" is selected as RelateDescription's ResultFormat, the function returns RelatedRecordSet as the Object property (QueryResult.Object).

 

Remarks

 

The ID property of MapLayerInfo or StandaloneTableInfo is used as SourceTableID.

 

An FIDSet needs to be created and assign an array of ObjectIDs to the FIDArray property. Related records for ObjectID(s) contained by the FIDSet will be queried.

 

RelateDescription contains information about relationship that will be explored. It needs to be created and populated with relates ID, list of fields and output result format.

 

When more than one ObjectID is passed, use SourceRowID on the RelatedRecordSet.RelatedRecordGroup to relate 'related rows' back to the source feature or row.

 

The result honors the fields visibility set in the layer or the standalone table.

 

Relates with non GeoDatabase Tables

 

This method relies on IDs of features or rows from the source layer/table, when a table does not have an OIDField (not a Geodatabase table), finding related records from the source layer/table from the destination table is not possible. For example, when a Parcel layer is related to an ownership table (for example from an Oracle database), you may find related ownership information for a parcel, but the function does not allow to find parcels belong to a owner. In order to traverse the other way a table must have a OIDField. You may consider one of the following options for this type of scenario:

 

 

Output Spatial and Time Reference

 

If the desired spatial reference of the output geometry is different than the original one, RelateDescription.OutputSpatialReference should be used. Otherwise geometry is returned in the same spatial reference system as the MapServerInfo.DefaultMapDescription by default.

 

Values in StartTimeFieldName or EndTimeFieldName are returned in the Layer's TimeReference. If the desired time reference is different than the layer's one, OutputTimeReference should be explicitly set.

 

 

 

Examples

C#