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


IQueryDef Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > Geodatabase > ESRI.ArcGIS.GeoDatabase > Interfaces > IQ > IQueryDef Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (GeoDatabase)  

IQueryDef Interface

Provides access to members that control attribute based queries.

Product Availability

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

Description

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.  

Members

Name Description
Method Evaluate Evaluate the query and return a cursor on the result set.
Read/write property SubFields The comma delimited list of field names for the query.
Read/write property Tables The comma delimited list of table names for the query.
Read/write property WhereClause The where clause for the query.

CoClasses that implement IQueryDef

CoClasses and Classes Description
QueryDef Esri Query Definition object.

Remarks

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.

[C#]

    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();
    }

See Also

IQueryFilter Interface

.NET Related Topics

Joining data