This class contains extension methods that extend ITable::Search method, which allow the Search method to return a .NET enumerable object instead of an ArcObjects COM cursor.
Methods
Name | Description |
---|---|
ITable.Search() | Return all features in the table. |
ITable.Search(String) | Return all features in the table matching the where clause. |
ITable.Search(String, Boolean) | Return all features in the table matching the where clause. Recycling behavior can also be controlled. |
ITable.Search() Method
Return all features in the table.
Note that the search is always performed with a recycling cursor meaning that individual IRow 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<IRow> rows = table.Search();
foreach (IRow row in rows)
{
// perform your operation
}
ITable.Search(String) Method
Return all features in the table matching the where clause.
public static IEnumerable<IRow> Search(this ITable tbl, 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 IRow 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<IRow> rows = table.Search("CITY_NAME='Redlands'");
int cnt = rows.Count();
ITable.Search(String, Boolean) Method
Return all features in the table matching the where clause. Recycling behavior can also be controlled.
Parameter | Description |
---|---|
where | Where clause. See IQueryFilter.WhereClause for the usage of the where clause string. |
recycling | See ITable::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<IRow> rows = table.Search("CITY_NAME='Redlands'", false);
int cnt = rows.Count();