This class contains extension methods that extend IFeatureClass::Search method, which allow the Search method to return a .NET enumerable object instead of an ArcObjects COM cursor.
Methods
Name | Description |
---|---|
IFeatureClass.Search() | Returns all features in the feature class with the recycling cursor. |
IFeatureClass.Search(String) | Returns all features in the feature class matching the given where clause with the recycling cursor. |
IFeatureClass.Search(String, Boolean) | Returns all features in the feature class matching the given where clause. Recycling behavior can also be controlled. |
IFeatureClass.Search(String, IGeometry) | Search the Feature Class for features matching the given where-clause and intersecting the given geometry with recycling cursor. |
IFeatureClass.Search(String, IGeometry, esriSpatialRelEnum) | Search the Feature Class for features matching the given where clause and having the given relationship to the input geometry with recycling cursor. |
IFeatureClass.Search(String, IGeometry, esriSpatialRelEnum, Boolean) | Search the Feature Class for features matching the given where clause and having the given relationship to the input geometry. |
IFeatureClass.Search() Method
Returns all features in the feature class with the recycling cursor. If you want to use non-recycling cursor, use IFeatureClass.Search(String, Boolean).
public static IEnumerable<IFeature> Search(this IFeatureClass fc)
Note that the search is always performed with a recycling cursor meaning that individual IFeature objects should not be referenced after the next object has been returned from the enumerator. The enumerator returned is a forward-only cursor that can only be used once and cannot be reused. Only one iteration via a foreach style loop or LINQ query operator, such as Count(), Where(), etc., is allowed. To reuse the enumerator, you must call the Search() method again. This method automatically releases the cursor after the iteration.
Usage:
IEnumerable<IFeature> features = featureClass.Search();
foreach (IFeature f in features)
{
// perform your operation
}
IFeatureClass.Search(String) Method
Returns all features in the feature class matching the given where clause with the recycling cursor.
public static IEnumerable<IFeature> Search(this IFeatureClass fc, string where)
Parameter | Description |
---|---|
where | Where clause. See IQueryFilter.WhereClause for the usage of the where clause string. |
Note that the search is always performed with a recycling cursor meaning that individual IFeature objects should not be referenced after the next object has been returned from the enumerator. The enumerator returned is a forward-only cursor that can only be used once and cannot be reused. Only one iteration via a foreach style loop or LINQ query operator, such as Count(), Where(), etc., is allowed. To reuse the enumerator, you must call the Search() method again. This method automatically releases the cursor after the iteration.
Usage:
IEnumerable<IFeature> features = featureClass.Search("CITY_NAME='Redlands'");
int cnt = features.Count();
IFeatureClass.Search(String, Boolean) Method
Returns all features in the feature class matching the given where clause. Recycling behavior can also be controlled. See recycling and non-recycling cursor.
Parameter | Description |
---|---|
where | Where clause. See IQueryFilter.WhereClause for the usage of the where clause string. |
recycling | See IFeatureClass.Search for the usage of the recycling parameter. |
The enumerator returned is a forward-only cursor that can only be used once and cannot be reused. Only one iteration via a foreach style loop or LINQ query operator, such as Count(), Where(), etc., is allowed. To reuse the enumerator, you must call the Search() method again. This method automatically releases the cursor after the iteration.
Usage:
//Use non-recycling parameter
IEnumerable<IFeature> features = featureClass.Search("CITY_NAME='Redlands'", false);
int cnt = features.Count();
IFeatureClass.Search(String, IGeometry) Method
Search the Feature Class for features matching the given where-clause and intersecting the given geometry with recycling cursor.
public static IEnumerable<IFeature> Search(this IFeatureClass fc, string where, IGeometry geometry)
Parameter | Description |
---|---|
where | Where clause. See IQueryFilter.WhereClause for the usage of the where clause string. |
geometry | Query geometry. See ISpatialFilter.Geometry for more details |
Only high-level geometries, envelopes and geometry bags can be used. High-level geometries are polygons, polylines, points, and multipoints. Low-level geometries including paths, rings, arcs and curves, and lines can not be used. To test whether a geometry is applicable, see if it implements the IRelationalOperator interface; if it does, it can be used. See ISpatialFilter.Geometry for more details.
Note that the search is always performed with a recycling cursor meaning that individual IFeature objects should not be referenced after a new object has been returned from the enumerator. The enumerator returned is a forward-only cursor that can only be used once and cannot be reused. Only one iteration via a foreach style loop or LINQ query operator, such as Count(), Where(), etc., is allowed. To reuse the enumerator, you must call the Search() method again. This method automatically releases the cursor after the iteration.
IFeatureClass.Search(String, IGeometry, esriSpatialRelEnum) Method
Search the Feature Class for features matching the given where clause and having the given relationship to the input geometry with recycling cursor.
public static IEnumerable<IFeature> Search(this IFeatureClass fc, string where, IGeometry geometry, esriSpatialRelEnum spatialRel)
Parameter | Description |
---|---|
where | Where clause. See IQueryFilter.WhereClause for the usage of the where clause string. |
geometry | Query geometry. See ISpatialFilter.Geometry for more details. |
spatialRel | Query spatial relationships. See ISpatialFilter.SpatialRel for more information. |
Note that the search is always performed with a recycling cursor meaning that individual IFeature objects should not be referenced after a new object has been returned from the enumerator. The enumerator returned is a forward-only cursor that can only be used once and cannot be reused. Only one iteration via a foreach style loop or LINQ query operator, such as Count(), Where(), etc., is allowed. To reuse the enumerator, you must call the Search() method again. This method automatically releases the cursor after the iteration.
IFeatureClass.Search(String, IGeometry, esriSpatialRelEnum, Boolean)
Search the Feature Class for features matching the given where clause and having the given relationship to the input geometry.
public static IEnumerable<IFeature> Search(this IFeatureClass fc, string where, IGeometry geometry, esriSpatialRelEnum spatialRel, bool recycling)
Parameter | Description |
---|---|
where | Where clause. See IQueryFilter.WhereClause for the usage of the where clause string. |
geometry | Query geometry. See ISpatialFilter.Geometry for more details. |
spatialRel | Query spatial relationships. See ISpatialFilter.SpatialRel for more information. |
recycling | See IFeatureClass.Search for the usage of the recycling parameter. |
The enumerator returned is a forward-only cursor that can only be used once and cannot be reused. Only one iteration via a foreach style loop or LINQ query operator, such as Count(), Where(), etc., is allowed. To reuse the enumerator, you must call the Search() method again. This method automatically releases the cursor after the iteration.