Data Access has been discontinued. Please refer to this page for more information.

MetaIndex

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

The MetaIndex class represents an index in the underlying table. During runtime, you could access all indexes that are available in the current container instance via the Indexes collection property of the MetadataContainer.

The MetaIndex class exposes the following properties:

  • Clustered - gets a value that indicates whether the index is clustered.
  • Unique - gets a value that indicates whether the index is unique.
  • Table - gets the MetaTable object that represents the table to which the index belongs.
  • Columns - gets a list of MetaIndexColumnMapping objects that describe the columns included in the index. The MetaIndexColumnMapping class represents an index column mapping in the Telerik Data Access meta model. It gives you information about:
    • Column - the column that this mapping is used for.
    • Position - the position in the index for this column.
    • SortOrder - whether the column order is ascending or descending.

The following examples shows you how to get information about the indexes in your domain model:

private string GetIndexes(Telerik.OpenAccess.Metadata.MetadataContainer container)
{
   StringBuilder sb = new StringBuilder();
   foreach (MetaIndex index in container.Indexes)
   {
       sb.AppendFormat("\nName: {0}", index.Name);
       sb.AppendLine("Columns:");
       foreach (MetaIndexColumnMapping mapping in index.Columns)
       {
           sb.AppendFormat("\tColumnName: {0}", mapping.Column.Name);
       }
   }
   return sb.ToString();
}
Private Function GetIndexes(ByVal container As Telerik.OpenAccess.Metadata.MetadataContainer) _
    As String
 Dim sb As New StringBuilder()
 For Each index As MetaIndex In container.Indexes
  sb.AppendFormat(vbLf & "Name: {0}", index.Name)
  sb.AppendLine("Columns:")
  For Each mapping As MetaIndexColumnMapping In index.Columns
   sb.AppendFormat(vbTab & "ColumnName: {0}", mapping.Column.Name)
  Next mapping
 Next index
 Return sb.ToString()
End Function

The following example shows a sample XML representation of a MetaTable element with two MetaColumns and a MetaIndex defined on the DepartmentID column:

<orm:table name="EmployeeDepartmentHistory" schema="HumanResources">
 <orm:column name="EmployeeID" sql-type="int" nullable="false" length="0" scale="0" 
    primary-key="true" ado-type="Int32" />
 <orm:column name="DepartmentID" sql-type="smallint" nullable="false" length="0" scale="0" 
    primary-key="true" ado-type="Int16" />  
 <orm:index name="IX_EmployeeDepartmentHistory_DepartmentID">
   <orm:columnMapping>
     <orm:column name="DepartmentID" sql-type="smallint" nullable="false" length="0" scale="0" 
        primary-key="true" ado-type="Int16" />
   </orm:columnMapping>
 </orm:index>
</orm:table>