IQueryDef Interface

Provides access to members that control attribute based queries.

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.

IQueryDefonly 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.

IQueryDef.Evaluate Method

Evaluate the query and return a cursor on the result set.

Public Function Evaluate ( _
) As ICursor
public ICursor Evaluate (
);

Remarks

The IQueryDef interface is used to set up and define the query and also provides an Evaluate method that is used to execute the query, returning a cursor.

IQueryDef.SubFields Property

The comma delimited list of field names for the query.

Public Property SubFields As String
public string SubFields {get; set;}

Description

SubFieldsreturns or sets a comma delimited list of fields.

Remarks

The following formats are used for the SubFields property of a QueryDef against an ArcSDE datasource:Format 1: "*"This returns all fields on all tables. If duplicate column names are found, the field names will be prefixed with the table name (table.field_name).Format 2: "field1,field2,field3"Returns only the fields requested. (Separate field names by commas but do not add a space after or before the comma)Format 3: "table1.*,table2.field1,table3.field2"Returns all of the fields from table1, field1 from table2 and field 2 from table3.

IQueryDef.Tables Property

The comma delimited list of table names for the query.

Public Property Tables As String
public string Tables {get; set;}

Description

Get or put a comma delimited string of tables for use in the query from the Tables data member.

Remarks

Returns a string containing the name of a single table (or a list of table names when used in a join). When used with an ArcSDE datasource, the table name will be prefixed with the owner name (owner.mytable) if the table is not owned by the current workspace.

IQueryDef.WhereClause Property

The where clause for the query.

Public Property WhereClause As String
public string WhereClause {get; set;}

Remarks

For more information about where clauses, see IQueryFilter.WhereClause.

Classes that implement IQueryDef

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.Tablesproperty it is the application developer's responsibility to ensure that only one shape attribute is specified in the IQueryDef.SubFieldsproperty.

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

    }

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.