Represents the criteria used to perform either an attribute or spatial search on a Table.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public sealed class Filter |
Visual Basic (Declaration) |
---|
Public NotInheritable Class Filter |
Remarks
A Filter object must be passed into the Search method to perform a query on a Table. All the possible query types can be set up using the appropriate constructor overload. Alternatively create a filter object and set the appropriate properties.
For more information on using the Filter class, 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 Munros 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