ADO.NET Provider for Microsoft Exchange

Build 24.0.9060

Indexes

You can retrieve information on indexes, such as the primary keys, by querying the Indexes collection.

Retrieving Primary Key Information

To retrieve this schema collection, call the GetSchema method of the ExchangeConnection class. You can restrict the results by table name. The following example retrieves the primary key of the Microsoft Exchange table Contacts.

C#

String connectionString = "User='[email protected]';Password='myPassword';Server='https://outlook.office365.com/EWS/Exchange.asmx';Platform='Exchange_Online';Schema='EWS';";

using (ExchangeConnection conn = new ExchangeConnection(connectionString)) {
  conn.Open();
  DataTable databaseSchema = conn.GetSchema("Indexes", new string[] {"Contacts"});
  foreach (DataRow row in databaseSchema.Rows) {
    Console.WriteLine(row["INDEX_NAME"]);
    Console.WriteLine(row["PRIMARY"]);
  }
}

VB.NET

Dim connectionString As String = "User='[email protected]';Password='myPassword';Server='https://outlook.office365.com/EWS/Exchange.asmx';Platform='Exchange_Online';Schema='EWS';"

Using conn As New ExchangeConnection(connectionString)
  conn.Open()
  Dim databaseSchema As DataTable = conn.GetSchema("Indexes",  New String() {"Contacts"})
  For Each row As DataRow In databaseSchema.Rows
    Console.WriteLine(row("INDEX_NAME"))
    Console.WriteLine(row("PRIMARY"))
  Next
End Using

Columns Returned

The Indexes schema collection contains the following columns:

Column NameData TypeDescription
INDEX_CATALOGSystem.StringThe name of the database containing the index.
INDEX_SCHEMASystem.StringThe name of the schema containing the index.
TABLE_NAMESystem.StringThe name of the table containing the index.
INDEX_NAMESystem.StringThe name of the index.
UNIQUESystem.BooleanWhether the index is unique.
PRIMARYSystem.BooleanWhether the index is a primary key.
TYPESystem.Int32An integer value corresponding to the index type: statistic (0), clustered (1), hashed (2), or other (3).
COMMENTSystem.StringA description of the index.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060