Assembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public class IndexCollection : IEnumerable<Index>, IEnumerable |
Visual Basic (Declaration) |
---|
Public Class IndexCollection _ Implements IEnumerable(Of Index), IEnumerable |
Remarks
An IndexCollection object can be returned from the Table.Indexes property.
You can find out about a Table's indexes by iterating over the collection and accessing each Index object. Alternatively use the GetNames method if you only want to know the names of the indexes or use the FindIndexesByColumnName method to return a collection that only contains Index objects involving the specified Column. For a spatially enabled Table, the HasSpatialIndex property indicates the presence of a spatial index for the spatial column.
Indexes are important as they improve both query performance and how quickly spatial features can be drawn on the display. You can manage the physical indexes defined against a Table using the Add and Delete methods.
Examples
//Open feature class Table countriesTable = Table.OpenFileGeodatabaseTable(@"C:\Data\World.gdb", "Countries"); //Return a collection containing all indexes in the Countries table IndexCollection indexes = countriesTable.Indexes; //Example 1 - Use a for each loop to iterate over all indexes in the collection foreach (Index indx in indexes) { //Print index name System.Diagnostics.Debug.Print(indx.Name); //Print whether the index is a unique index System.Diagnostics.Debug.Print(string.Format("Unique: {0}", indx.IsUnique.ToString())); //Print whether the index is an ascending index System.Diagnostics.Debug.Print(string.Format("Ascending: {0}", indx.IsAscending.ToString())); } //Example 2 - alternative approach - use a for/next loop to iterate over all indexes in the collection by "index" position for (int i = 0; i < indexes.Count; i++) { Index ind = indexes[i]; //Print the name of each index System.Diagnostics.Debug.Print(ind.Name); } //Example 3 - access a specific index by Name Index capitalIndex = indexes["Capital"];
'Open feature class Dim countriesTable As Table = Table.OpenFileGeodatabaseTable("C:\Data\World.gdb", "Countries") 'Return a collection containing all indexes in the Countries table Dim indexes As IndexCollection = countriesTable.Indexes 'Example 1 - Use a for each loop to iterate over all indexes in the collection For Each indx As Index In indexes 'Print index name System.Diagnostics.Debug.Print(indx.Name) 'Print whether the index is a unique index System.Diagnostics.Debug.Print(String.Format("Unique: 0", indx.IsUnique.ToString())) 'Print whether the index is an ascending index System.Diagnostics.Debug.Print(String.Format("Ascending: 0", indx.IsAscending.ToString())) Next 'Example 2 - alternative approach - use a for/next loop to iterate over all indexes in the collection by "index" position For i As Integer = 0 To indexes.Count - 1 Dim ind As Index = indexes.Item(i) 'Print the name of each index System.Diagnostics.Debug.Print(ind.Name) Next 'Example 3 - access a specific index by Name Dim capitalIndex As Index = indexes.Item("Capital")