ITableForeignKeys.FindByKey

Fore Syntax

FindByKey(Key: Integer): ITableForeignKey;

Fore.NET Syntax

FindByKey(Key: uinteger): Prognoz.Platform.Interop.Db.ITableForeignKey;

Parameters

Key. Key of an external key.

Description

The FindByKey method searches for the external key in the collection by its personal key.

Comments

If an external key with selected key is not found, the method returns Null.

Fore Example

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

Add links to the Metabase, Db system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Table: ITable;
    FKeys: ITableForeignKeys;
    Key: ITableForeignKey;
Begin
    mb := MetabaseClass.Active;
    Table := mb.ItemById("TABLE_L").Bind As ITable;
    FKeys := Table.ForeignKeys;
    If FKeys.Count > 0 Then
        Key := FKeys.FindByKey("2");
        If Key <> Null Then
            Debug.WriteLine(Key.Name);
        End If;
    End If;
End Sub UserProc;

After executing the example the external key with the key 2 is searched for in the TABLE_L table. If the external key is found, its name is displayed in the console window.

Fore.NET Example

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

Imports Prognoz.Platform.Interop.Db;

[STAThread]
Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    Table: ITable;
    FKeys: ITableForeignKeys;
    Key: ITableForeignKey;
Begin
    mb := Params.Metabase;
    Table := mb.ItemById["TABLE_L"].Bind() As ITable;
    FKeys := Table.ForeignKeys;
    If FKeys.Count > 0 Then
        Key := FKeys.FindByKey("2");
        If Key <> Null Then
            System.Diagnostics.Debug.WriteLine(Key.Name);
        End If;
    End If;
End Sub;

After executing the example the external key with the key 2 is searched for in the TABLE_L table. If the external key is found, its name is displayed in the console window.

See also:

ITableForeignKeys