Initializes a new instance of the Index class which can be used to create a new named, composite (multi-column) index on disk when it is added to the IndexCollection. This constructor only applies to file geodatabase tables and feature classes.

Namespace:  ESRI.ArcGISExplorer.Data

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

Syntax

C#
public Index(
	string indexName,
	string[] columnNames
)
Visual Basic (Declaration)
Public Sub New ( _
	indexName As String, _
	columnNames As String() _
)

Parameters

indexName
Type: System..::.String

Name of the index.
columnNames
Type: array< System..::.String >[]()[]

An Array of column names on which to create the composite index.

Remarks

The following properties use their default values:

  • IsUnique property is set to falseFalsefalsefalse (False in Visual Basic).
  • IsAscending property is set to trueTruetruetrue (True in Visual Basic).

Examples

The code below demonstrates how to create a new composite index on three columns in a file geodatabase feature class. A new Index object is created specifying the name of the index and the names of the columns to index. The Index object is then added to the IndexCollection to create the index on disk. The properties of the Index object are printed out, including the names of the columns which participate in the index using the GetColumnNames method.
CopyC#
{
  //Open the countries file geodatabase feature class
  Table countriesTable = Table.OpenFileGeodatabaseTable(@"C:\Data\World.gdb","countries");

  //Get the IndexCollection
  IndexCollection indexes = countriesTable.Indexes;

  //Create string array of columns that will make up the composite index
  string[] columnsToIndex = {"Name", "Region", "Continent"};

  //Create a new Index object
  Index compositeIndex = new Index("idx_Composite", columnsToIndex);

  try
  {
    //Add the Index to the IndexCollection thereby creating it on disk.
    indexes.Add(compositeIndex);

    //Print out the index properties
    System.Diagnostics.Debug.Print(compositeIndex.Name);                     //Prints "idx_Composite"
    System.Diagnostics.Debug.Print(compositeIndex.IsAscending.ToString());   //Prints "True"
    System.Diagnostics.Debug.Print(compositeIndex.IsUnique.ToString());      //Prints "False"
    foreach (string columnName in compositeIndex.GetColumnNames())
    {
      System.Diagnostics.Debug.Print(columnName);                       
    }

    //Prints: 
    //"Name"
    //"Region"
    //Continent

  }
  catch (Exception ex)
  {
    System.Diagnostics.Debug.Print(ex.Message);
  }
}
CopyVB.NET
'Open the countries file geodatabase feature class
Dim countriesTable As Table = Table.OpenFileGeodatabaseTable("C:\Data\World.gdb", "countries")

'Get the IndexCollection
Dim indexes As IndexCollection = countriesTable.Indexes

'Create string array of columns that will make up the composite index
Dim columnsToIndex As String() = {"Name", "Region", "Continent"}

'Create a new Index object
Dim compositeIndex As Index = New Index("idx_Composite", columnsToIndex)

Try
  'Add the Index to the IndexCollection thereby creating it on disk.
  indexes.Add(compositeIndex)

  'Print out the index properties
  System.Diagnostics.Debug.Print(compositeIndex.Name)                     'Prints "idx_Composite"
  System.Diagnostics.Debug.Print(compositeIndex.IsAscending.ToString())   'Prints "True"
  System.Diagnostics.Debug.Print(compositeIndex.IsUnique.ToString())      'Prints "False"


  For Each columnName As String In compositeIndex.GetColumnNames()
    System.Diagnostics.Debug.Print(columnName)
  Next

  'Prints: 
  '"Name"
  '"Region"
  'Continent


Catch ex As Exception
  System.Diagnostics.Debug.Print(ex.Message)
End Try

See Also