IQueryName Interface

Provides access to the associated query definition.


Name Description
Read/write property QueryDef QueryDef of feature class name.

IQueryName.QueryDef Property

QueryDef of feature class name.

Public Property QueryDef As IQueryDef
public IQueryDef QueryDef {get; set;}


public void IQueryName__(IWorkspace workspace){IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;IQueryDef queryDef = featureWorkspace.CreateQueryDef();//examples of query def construction

//Valid sub fieldsqueryDef.SubFields = "Parcel.Area, Parcel.Parcel_ID";//Invalid sub fields//queryDef.SubFields = "max(Parcel.Area) as Max_Area";

//Valid tablesqueryDef.Tables = "Parcels, Owners";//Invalid tables//queryDef.Tables = "Parcels p, Owners o";//queryDef.Tables = "Owners INNER JOIN parcels ON Owners.Parcel_id = parcels.Parcel_id";

//Valid where clausequeryDef.WhereClause = "Owner.Name like '%Smith%' and Owner.Address like '%Main Street%'";//Invalid where clause//queryDef.WhereClause = "Owner.Name like '%Smith%' group by Owner.City_Address";

//set QueryDef propertyIQueryName queryName = new TableQueryNameClass();queryName.QueryDef = queryDef;}


The IQueryDef::Subfields, IQueryDef::Tables and IQueryDef::WhereClause properties of the QueryDef are used to generate a SQL statement. This is executed against the database to return the rows represented by the table or feature class opened from the name object. If the QueryDef properties are not set properly, you may get errors or incorrect results. The following describes how to define these properties properly:

IQueryDef::Subfields - This must be a comma delimited list of field names or a * to indicate all columns. Column aliases and functions are invalid.

IQueryDef::Tables - This needs to be a comma delimited list of tables. Join statements or table aliases are invalid.

IQueryDef::WhereClause - Most WhereClauses are valid, but additonal statements like Order by and Group by are not.

See the IQueryDef interface for more information on QueryDefs. 

Classes that implement IQueryName

Classes Description
FeatureQueryName Esri Feature Query Name object.
TableQueryName Esri Table Query Name object.
public void IQueryName__(IWorkspace workspace)


        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;

        IQueryDef queryDef = featureWorkspace.CreateQueryDef();

        //examples of query def construction

        //Valid sub fields

        queryDef.SubFields = "Parcel.Area, Parcel.Parcel_ID";

        //Invalid sub fields

        //queryDef.SubFields = "max(Parcel.Area) as Max_Area";

        //Valid tables

        queryDef.Tables = "Parcels, Owners";  

        //Invalid tables

        //queryDef.Tables = "Parcels p, Owners o";

        //queryDef.Tables = "Owners INNER JOIN parcels ON Owners.Parcel_id = parcels.Parcel_id";

        //Valid where clause

        queryDef.WhereClause = "Owner.Name like '%Smith%' and Owner.Address like '%Main Street%'";

        //Invalid where clause

        //queryDef.WhereClause = "Owner.Name like '%Smith%' group by Owner.City_Address";

        //set QueryDef property

        IQueryName queryName = new TableQueryNameClass();

        queryName.QueryDef = queryDef;


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