Map service QueryRowCount method
Queries and returns the number of features from a table or a layer that meet the query filter selection criteria for the specified layer or table description.
The name of the map (data frame) that contains the layer associated with the MapTableDescription parameter.
Used to set the definition expression to a layer or a standalone table.
An attribute or spatial query that defines the selection criteria for the layer or standalone table associated with the MapTableDescription parameter.
An integer value indicating the number of features that meet the selection criteria. A SOAP exception will be thrown when the SQL expression in the query filter is invalid.
The QueryFilter can be an attribute query (SQL espression), a spatial query, or a combination of both.
QueryFilter provides the ability to query based on attribute filter (SQL expression) a spatial filter, or a combination of both.
- Attribute filters take any valid 'non-GIS data specific' SQL statement. For example, "CNTRY_CODE = 'BD'" or "POPULATION = 12345".
- Syntax for querying date fields depends on the underlying data. If you are working with shapefiles or a file geodatabase, the syntax is <FieldName> = date 'YYYY-MM-DD'; for Access-based personal geodatabases the syntax is #YYYY-MM-DD#. For SDE databases, check with the specific database's help.
These never apply to standalone tables since they contain no geometry does not contain geometry. If a spatial filter is used for a standalone table, the geometry set in SpatialFilter.FilterGeometry is ignored. The geometry in a spatial filter should meet the following criteria:
- It should have the spatial reference system defined. In cases where it is not defined, the coordinate system is assumed to be in the DataFrame's coordinate system.
- It must be one of the high-level geometries i.e. Point, Multipoint, Polyline, Polygon or Multipatch. Low-level geometry like a BezierCurve must be wrapped into a high-level geometry.
- It must be topologically correct. For more information, see Remarks on Polygon.
A DefinitionExpression can be set on a layer in order to limit layer features available for display or query. This expression can be 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 the 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:
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 a count of all sale region features that fall within the North region and are managed by Bob.
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 a count of 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'".
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 a count of all sale region features with sales over 1000 and are managed by Bob. This method honors the DefinitionExpression set in LayerDescription.
There are two key differences between Find and this method:
- The first is that Find can work on multiple layers while the query methods work with a single layer.
- 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.