ITableExtensions Class

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

NameDescription
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:

Use dark colors for code blocksCopy
1
2
3
4
5
    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.

Use dark colors for code blocksCopy
1
public static IEnumerable<IRow> Search(this ITable tbl, string where)
ParameterDescription
whereWhere 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:

Use dark colors for code blocksCopy
1
2
    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.

ParameterDescription
whereWhere clause. See IQueryFilter.WhereClause for the usage of the where clause string.
recyclingSee 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 dark colors for code blocksCopy
1
2
3
    //Use non-recycling parameter
    IEnumerable<IRow> rows = table.Search("CITY_NAME='Redlands'", false);
    int cnt = rows.Count();

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