IDimIndexAttributes.FindByKey

Fore Syntax

FindByKey(AttributeKey: Integer): IDimAttribute;

Fore.NET Syntax

FindByKey(AttributeKey: uinteger): Prognoz.Platform.Interop.Dimensions.IDimAttribute;

Parameters

AttributeKey. Key of the attribute, by which the search is executed.

Description

The FindByKey method finds attribute in the index by its key.

Comments

If an attribute with the specified key is not included into index, the method returns Null.

Fore Example

Executing the example requires that the repository contains a table dictionary with the D_TO identifier.

Add links to the Dimensions, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    DimModel: IDimensionModel;
    Index: IDimIndex;
    IndAtr: IDimIndexAttributes;
    Atr: IDimAttribute;
Begin
    
// Get current repository
    MB := MetabaseClass.Active;
    
// Get dictionary
    DimModel := MB.ItemById("D_TO").Bind As IDimensionModel;
    
// Get the first dictionary index
    Index := DimModel.Indexes.Item(0);
    
If Index <> Null Then
        
// Get attributes of the first dictionary index
        IndAtr := Index.Attributes;
        
// Search for attribute by key
        Atr := IndAtr.FindByKey(2);
        
If Atr <> Null Then
            Debug.WriteLine(
"Found attribute name: " + Atr.Name);
        
Else
            Debug.WriteLine(
"Attribute is not found");
        
End If;
    
End If;
End Sub

After executing the example the attribute with the 2 key is searched in the dictionary first index. If the attribute is found, its name is displayed in the console window.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Dimensions;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    DimModel: IDimensionModel;
    Index: IDimIndex;
    IndAtr: IDimIndexAttributes;
    Atr: IDimAttribute;
Begin
    // Get current repository
    MB := Params.Metabase;
    // Get dictionary
    DimModel := MB.ItemById["D_TO"].Bind() As IDimensionModel;
    // Get the first dictionary index
    Index := DimModel.Indexes.Item[0];
    If Index <> Null Then
        // Get attributes of the dictionary index
        IndAtr := Index.Attributes;
        // Search for attribute by key
        Atr := IndAtr.FindByKey(2);
        If Atr <> Null Then
            System.Diagnostics.Debug.WriteLine("Found attribute name: " + Atr.Name);
        Else
            System.Diagnostics.Debug.WriteLine("Attribute is not found");
        End If;
    End If;
End Sub;

See also:

IDimIndexAttributes