Returns a collection of rows from the Table which satisfy the search criteria specified by the Filter object.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public RowCollection Search( Filter filter ) |
Visual Basic (Declaration) |
---|
Public Function Search ( _ filter As Filter _ ) As RowCollection |
Parameters
- filter
- Type: ESRI.ArcGISExplorer.Data..::.Filter
A Filter object containing the search criteria which consists of a SQL clause for an attribute query or a geometry and spatial relationship for a spatial query.
Return Value
A RowCollection object which contains Row objects each of which represents a record in the Table.Remarks
For more information on using the Search method, see How to Search a Table.
Examples
The code below provides two examples of searching a Table. The first is an SQL-based query to find all
mountains which are classified as being a Munro in the Type column and the second performs a spatial search
to find all mountains within the Edinburgh region.
CopyC#
//Open the mountains and regions feature classes stored in the Scotland file geodatabase Geodatabase gdb = new Geodatabase(@"C:\Data\Scotland.gdb"); Table mountainsTable = gdb.OpenTable("mountains"); Table regionsTable = gdb.OpenTable("regions"); //Example 1 //Perform a SQL-based, attribute query to find all mountains classified as being Munros RowCollection rows = mountainsTable.Search(new Filter("Type = 'Munro'")); foreach (Row mtn in rows) { //Print the name of each Munro that is stored in the Name column System.Diagnostics.Debug.Print(mtn.Values["Name"].ToString()); } //Example 2 //Perform a spatial query to find all mountains contained within the Edinburgh region //get row for Edinburgh from Regions table Row edinRow = regionsTable.GetRow(5); //perform a spatial search rows = mountainsTable.Search(new Filter(edinRow.Geometry, FilterSearchOptions.Contains)); foreach (Row mtn in rows) { //Print the name of each mountain that is stored in the Name column System.Diagnostics.Debug.Print(mtn.Values["Name"].ToString()); }
CopyVB.NET
'Open the mountains and regions feature classes stored in the Scotland file geodatabase Dim gdb As Geodatabase = New Geodatabase("C:\Data\Scotland.gdb") Dim mountainsTable As Table = gdb.OpenTable("mountains") Dim regionsTable As Table = gdb.OpenTable("regions") 'Example 1 'Perform a SQL-based, attribute query to find all mountains classified as being Munros Dim rows As RowCollection = mountainsTable.Search(New Filter("Type = 'Munro'")) For Each mtn As Row In rows 'Print the name of each Munro that is stored in the Name column System.Diagnostics.Debug.Print(mtn.Values.Item("Name")) Next 'Example 2 'Perform a spatial query to find all mountains contained within the Edinburgh region 'get row for Edinburgh from Regions table Dim edinRow As Row = regionsTable.GetRow(5) 'perform a spatial search rows = mountainsTable.Search(New Filter(edinRow.Geometry, FilterSearchOptions.Contains)) For Each mtn As Row In rows 'Print the name of each mountain that is stored in the Name column System.Diagnostics.Debug.Print(mtn.Values.Item("Name")) Next