ADO.NET Provider for Azure DevOps

Build 24.0.9060

Index Columns

The IndexColumns schema collection lists the indexes and their corresponding columns. By filtering on indexes, you can write more selective queries with faster query response times.

Retrieving Index Column Information

To retrieve this schema collection, call the GetSchema method of the AzureDevOpsConnection class. You can restrict the results by table name. The following example retrieves the column and sequence number for each index of the Azure DevOps table WorkItems.

C#

String connectionString = "AuthScheme=Basic;Organization=MyAzureDevOpsOrganization;Catalog=Project_dev;Schema=Project;PersonalAccessToken=MyPAT;";

using (AzureDevOpsConnection conn = new AzureDevOpsConnection(connectionString)) {
  conn.Open();
  DataTable databaseSchema = conn.GetSchema("IndexColumns", new string[] {"WorkItems"});
  foreach (DataRow row in databaseSchema.Rows) {
    Console.WriteLine(row["COLUMN_NAME"]);
    Console.WriteLine(row["ORDINAL_POSITION"]);
  }
}

VB.NET

Dim connectionString As String = "AuthScheme=Basic;Organization=MyAzureDevOpsOrganization;Catalog=Project_dev;Schema=Project;PersonalAccessToken=MyPAT;"

Using conn As New AzureDevOpsConnection(connectionString)
  conn.Open()
  Dim databaseSchema As DataTable = conn.GetSchema("IndexColumns",  New String() {"WorkItems"})
  For Each row As DataRow In databaseSchema.Rows
    Console.WriteLine(row["COLUMN_NAME"])
    Console.WriteLine(row["ORDINAL_POSITION"])
  Next
End Using

Columns Returned

The IndexColumns schema collection returns 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.
COLUMN_NAMESystem.StringThe name of the column associated with the index.
ORDINAL_POSITIONSystem.Int32The sequence number of the column.
SORT_ORDERSystem.Int32Returns A for ascending and D for descending.

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