Create a query filter
Query filters allow you to use attribute data to create a subset of your original data. They are used for many different tasks in ArcObjects, such as selecting features in a layer or creating a subset of the features and performing an operation on those features alone. It is important to note that a spatial filter implements IQueryFilter so you can use a query filter in a spatial query as well. When creating a query based upon a string attribute be sure to enclose your string condition in single quotes (e.g. "name='ESRI'")
QueryFilter queryFilter = new QueryFilter();queryFilter.setWhereClause("Attribute=value");
Select features from a layer based upon attributes
Once you have a query filter you can use it to select features in a layer. The second parameter of the selectFeatures method allows you to determine what type of selection to perform, such as create a new selection set, append the selection to the current selection set, and several others.
layer.selectFeatures(queryfilter,esriSelectionResultEnum.esriSelectionResultNew,false);int numberOfSelectedFeatures = map.getSelectionCount();
Perform a spatial query on a map
A spatial filter, which also implements IQueryFilter, searches a feature class for all the features which satisfy the spatial relation with an IGeometry. There are many objects which implement IGeometry, such as Point, MultiPoint, Line, and so on. The list of spatial relations can be found in esriSpatialRelEnum.
SpatialFilter spatialFilter = new SpatialFilter(); spatialFilter.setGeometryByRef(searchGeometry);String shapeFieldString = featureClass.getShapeFieldName();spatialFilter.setGeometryField(shapeFieldString);spatialFilter.setSpatialRel(spatialRelation);
if ((whereClause == null )){
spatialFilter.setWhereClause("");} else { spatialFilter.setWhereClause(whereClause);}
featureCursor = featureClass.search(spatialFilter,false);
9.2 Help EDN quickstart page
ImapClipOption