This document is archived and information here might be outdated.  Recommended version.


IMapServer2.QueryFeatureIDs2 Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > IM > IMapServer2 Interface > IMapServer2.QueryFeatureIDs2 Method
ArcGIS Developer Help

IMapServer2.QueryFeatureIDs2 Method

Returns the IDs of the features that meet the query filter selection criteria for the specified layer.

[Visual Basic .NET]
Public Function QueryFeatureIDs2 ( _
    ByVal MapName As String, _
    ByVal pLayerDesciscription As ILayerDescription, _
    ByVal Filter As IQueryFilter _
) As IFIDSet
[C#]
public IFIDSet QueryFeatureIDs2 (
    string MapName,
    ILayerDescription pLayerDesciscription,
    IQueryFilter Filter
);
[C++]
HRESULT QueryFeatureIDs2(
  BSTR MapName,
  ILayerDescription* pLayerDesciscription,
  IQueryFilter* Filter
);
[C++]
Parameters
MapName [in]

MapName is a parameter of type BSTR pLayerDesciscription [in]
pLayerDesciscription is a parameter of type ILayerDescription* Filter [in]
Filter is a parameter of type IQueryFilter*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

QueryFeatureIDs2 returns the IDs (FIDSet) of map features that match the parameters of a given query filter.

QueryFeatureIDs2 requires a number of input parameters. These include: a MapName, LayerID, and a QueryFilter. The QueryFilter can be an attribute query (SQL espression), a spatial query, or a combination of both.

QueryFilter 

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 depend on the underlying data. If you are working with Shapefile or File GeoDatabase data the syntax is <FieldName> = date ‘YYYY-MM-DD’; for Access-based Personal GeoDatabase the sytax is #YYYY-MM-DD#. For SDE database, check with the specific database’s help.

SearchShape 

Geometry set in ISpatialFilter should meet the following criteria:

DefinitionExpressions

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 will override any definition query set in the source map. MapServer QueryFeatureIDs2 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 DefintionExpression is specified in LayerDescription. Your QueryFilter where clause is "MANAGER = 'Bob'". The result will be the ids of 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 the ids of all sale region features with sales over 1000 and are managed by Bob. QueryFeatureIDs2 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 defintion 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 the ids of all sale region features with sales over 1000 and are managed by Bob. QueryFeatureIDs2 honors the DefinitionExpression set in LayerDescription.

Miscellaneous

MaxRecordCount does not affect QueryFeatureIDs or QueryFeatureIDs2.

There are two key differences between Find and QueryFeatureIDs2. 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.

The results of this function can be used with LayerDescription::SelectionFeatures to display the selection in the exported image.

See Also

IMapServer2 Interface