Map Service QueryRowIDs method

Queries and returns a set of object ids that meet the query filter selection criteria for the specified layer or table description.

 

QueryRowIDs(string MapName, MapTableDescription MapTableDescription, QueryFilter QueryFilter)

 

Parameter

Description

MapName

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

MapTableDescription

Used to set the definition expression to a layer or a standalone table.

QueryFilter

An attribute or spatial query that defines the selection criteria for the layer or standalone table associated with the MapTableDescription parameter.

 

Return Value

 

The function returns an array of integers (int[]) unlike QueryFeatureIDs or QueryFeatureIDs2. Each integer represents a unique identifier for each feature (FID) or row in the layer or table queried. The map service assigns FIDs to each feature in every feature layer it contains. A SOAP exception will be thrown if the SQL expression in the query filter is invalid.

 

Remarks

 

The QueryFilter can be an attribute query (SQL expression), a spatial query, or a combination of both.

 

MapTableDescription is an identifier class implemented by LayerDescription and StandaloneTableDescription classes. LayerDescription for a layer can be obtained from MapServerInfo.DefaultMapDescription while StandaloneTableDescription can be obtained using MapServerInfo.StandaloneTableDescriptions properties.

 

QueryFilter

 

QueryFilter provides the ability to query based on attribute filter (SQL expression) a spatial filter, or a combination of both.

 

Attribute Filters:

 

Spatial Filters:

 

Geometry is only required for spatial query since a table does not contain geometry. If a spatial filter is used for a standalone table, the Geometry set in SpatialFilter.FilterGeometry is ignored. Spatial filter geometry should meet the following criteria:

 

 

Definition Expressions

 

A DefinitionExpression can be set on a layer or a standalone table in order to limit layer features or rows available for display or query. This expression can also be set in the source map document as a definition query. Any DefinitionExpression set in the LayerDescription or StandaloneTableDescription will override any definition query set in the source map. This method honors DefinitionExpression.

 

Let's look at some examples. You have a layer in your map that represents sales regions. The layer includes fields REGIONS, SALES and MANAGER.

 

Example #1: In the source map the layer has a definition query, "REGION = 'North'". No DefinitionExpression is specified in LayerDescription. Your QueryFilter where clause is "MANAGER = 'Bob'". The result will be all sale region features that fall within the North region and are managed by Bob.

 

Example #2: In the source map the layer has a definition query, "REGION = 'North'". You apply a DefinitionExpression in LayerDescription as "SALES > 1000". Your QueryFilter where clause is "MANAGER = 'Bob'". The result will be all sale region features with sales over 1000 and are managed by Bob. This method honors the DefinitionExpression set in LayerDescription. The DefinitionExpression overrides the definition query set in the source map. If you wish to include the layer's original definition query, "REGION = 'North'" in your final query, you must include this in your QueryFilter, ""MANAGER = 'Bob' AND "REGION = 'North'".

 

Example #3: In the source map the layer has no definition query. You apply a DefinitionExpression in LayerDescription as "SALES > 1000". Your QueryFilter where clause is "MANAGER = 'Bob'". The result will be all sale region features with sales over 1000 and are managed by Bob. QueryData honors the DefinitionExpression set in LayerDescription.

 

Page through Result

 

Results from QueryRowIDs can be used to page through a result. When a query is expected to return a lot of rows and showing all those records on a single page is not desirable, you may use the following steps to page through your result and get records for a selected subset on demand:

 

 

Miscellaneous

 

The maximum record count set on the Service (GetServiceConfigurationInfo.MaxRecordCount) does not affect this method or QueryRowCount.

 

There are two key differences between Find and this method:

 

  1. The first is that Find can work on multiple layers while the query methods work with a single layer.

  2. The second is that Find only works with a search string. The query methods use a QueryFilter as a parameter. This allows the query to be based on either an attribute filter (SQL expression) or a spatial filter.

 

The results of this function can be wrapped up in a FIDSet and be used with LayerDescription.SelectionFeatures to display the selection in the exported image.