This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Geodatabase > ESRI.ArcGIS.GeoDatabase > Interfaces > IQ > IQueryDef Interface (ArcObjects .NET 10.4 SDK) |
Provides access to members that control attribute based queries.
IQueryDef sets the parameters needed to create an attribute query. The name of the table and a string defining the where clause are required. An optional list of columns may be included to specify the columns to be retrieved. If no columns are specified, all columns will be returned.
IQueryDef only can be used with ArcSDE, Personal and File Geodatabase data sources. QueryDef cursor are not supported on historical representations of datasets.
Description | ||
---|---|---|
Evaluate | Evaluate the query and return a cursor on the result set. | |
SubFields | The comma delimited list of field names for the query. | |
Tables | The comma delimited list of table names for the query. | |
WhereClause | The where clause for the query. |
CoClasses and Classes | Description |
---|---|
QueryDef | Esri Query Definition object. |
The IQueryDef interface allows the definition of an attribute query based on one or more tables. Multiple table joins may be defined through the use of this interface.
In order to access the geometry of a feature returned by the query the shape field must be included in the SubFields definition.
If multiple feature classes are specified in the IQueryDef.Tables property it is the application developer's responsibility to ensure that only one shape attribute is specified in the IQueryDef.SubFields property.
public void IQueryDef__(IWorkspace workspace)
{
IFeatureWorkspace featureWorkspace=(IFeatureWorkspace)workspace;
IQueryDef queryDef=featureWorkspace.CreateQueryDef();
//Setting the SubFields, Tables, and WhereClause:
//Single table with a WhereClause
queryDef.Tables="STATES";
queryDef.SubFields="*";
queryDef.WhereClause="STATE_NAME='California'";
//Multiple tables with a join.
queryDef.Tables="STATES,STATEPOP,STATEAGE";
queryDef.SubFields="*";
queryDef.WhereClause="STATESID=POPID and POPID=AGEID";
//Using Evaluate:
ICursor cursor;
cursor=queryDef.Evaluate();
}