Represents a physical index on a column or columns in a Table which is stored on disk.

Namespace:  ESRI.ArcGISExplorer.Data

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public sealed class Index
Visual Basic (Declaration)
Public NotInheritable Class Index

Remarks

A physical index will not be created for an Index object until it added to the IndexCollection using the Add method.

Existing indexes cannot be modified. Setting properties or calling the methods on an existing Index object will have no affect as they are designed to be used when creating a new Index. To workaround this you will need to Delete the Index, then re-create it.

Examples

The code below, which would be suitable for a dockable window add-in, presents a scenario where the user can build an index against any column in the selected feature layer. The Add method is used to add the Index to the IndexCollection, thereby creating it on disk.
CopyC#
//Get first selected map item
MapItem firstSelectedMapItem = ESRI.ArcGISExplorer.Application.Application.SelectedItems[0];

//Exit if either no selection or if selection is not a FeatureLayer
if ((firstSelectedMapItem == null) || !(firstSelectedMapItem is FeatureLayer))
  return;

//Get selected feature layer
FeatureLayer someFeatureLayer = firstSelectedMapItem as FeatureLayer;

//Get the Table
Table someTable = someFeatureLayer.Table;

//Indexes cannot be created for ArcSDE data so check for this.
object dataContainer = someTable.RootDataContainer;
if (dataContainer is Geodatabase)
{
  Geodatabase gdb = dataContainer as Geodatabase;
  if (gdb.Type == GeodatabaseType.ArcSDE)
    return;
} 

//Get the IndexCollection for the Table
IndexCollection indexes = someTable.Indexes;

//Simulated code to represent a user selecting an item from a list of column names
System.Windows.Forms.ListBox columnsListBox = new System.Windows.Forms.ListBox();
string columnName = columnsListBox.SelectedItem.ToString();

//Check whether the column already participates in any indexes
if (indexes.FindIndexesByColumnName(columnName).Count == 0)
{
  try
  {
    //Create the new index
    string indexName = string.Format("idx_ {0}",columnName);
    Index newIndex = new Index(indexName, columnName); //if shapefile the index name parameter will be ignored
    //Add it to the IndexCollection
    indexes.Add(newIndex);
  }
  catch (Exception ex)
  {
    System.Windows.Forms.MessageBox.Show(string.Format("It was not possible to build an index for the {0} column: {1}",columnName, ex.Message));
  }
}
CopyVB.NET
'Get first selected map item
Dim firstSelectedMapItem As MapItem = ESRI.ArcGISExplorer.Application.Application.SelectedItems.Item(0)

'Exit if either no selection or if selection is not a FeatureLayer
If firstSelectedMapItem Is Nothing Or Not TypeOf firstSelectedMapItem Is FeatureLayer Then
  Return
End If

'Get selected feature layer
Dim someFeatureLayer As FeatureLayer = DirectCast(firstSelectedMapItem, FeatureLayer)

'Get the Table
Dim someTable As Table = someFeatureLayer.Table

'Indexes cannot be created for ArcSDE data so check for this.
Dim dataContainer As Object = someTable.RootDataContainer
If TypeOf dataContainer Is Geodatabase Then
  Dim gdb As Geodatabase = DirectCast(dataContainer, Geodatabase)
  If gdb.Type = GeodatabaseType.ArcSDE Then
    Return
  End If
End If

'Get the IndexCollection for the Table
Dim indexes As IndexCollection = someTable.Indexes

'Simulated code to represent a user selecting an item from a list of column names
Dim columnsListBox As System.Windows.Forms.ListBox = New System.Windows.Forms.ListBox()
Dim columnName As String = columnsListBox.SelectedItem.ToString()

'Check whether the column already participates in any indexes
If indexes.FindIndexesByColumnName(columnName).Count = 0 Then
  Try
    'Create the new index
    Dim indexName As String = String.Format("idx_ 0", columnName)
    Dim newIndex As Index = New Index(indexName, columnName) 'if shapefile the index name parameter will be ignored
    'Add it to the IndexCollection
    indexes.Add(newIndex)
  Catch ex As Exception
    System.Windows.Forms.MessageBox.Show(String.Format("It was not possible to build an index for the 0 column: 1", columnName, ex.Message))
  End Try
End If

Inheritance Hierarchy

System..::.Object

  ESRI.ArcGISExplorer.Data..::.Index

See Also