IRdsLinks.Add

Syntax

Add: IRdsLink;

Description

The Add method creates the MDM dictionary link.

Comments

It is not possible to create a link for the dictionaries built on different database objects.

Example

Executing the example requires the MDM repository with the NSI_LINK identifier that contains MDM dictionaries with the Dict_1 and Dict_2 identifiers. The unique GUID identifier must be available in elements for the second dictionary.

Add links to the Metabase, Rds, Dal system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MObj, MObj2: IMetabaseObject;
    Dict, Dict2: IRdsDictionary;
    Attrs: IRdsAttributes;
    LinkAttr, LookupAttr: IRdsAttribute;
    Link: IRdsLink;
Begin
    MB := MetabaseClass.Active;
    MObj := MB.ItemByIdNamespace("Dict_1", MB.ItemById("NSI_LINK").Key).Edit;
    Dict := MObj As IRdsDictionary;
    MObj2 := MB.ItemByIdNamespace("Dict_1", MB.ItemById("NSI_LINK").Key).Bind;
    Dict2 := MObj2 As IRdsDictionary;
    //Attributes of the first dictionary
    Attrs := Dict.Attributes;
    //Attribute to link with the dictionary
    LinkAttr := Attrs.Add;
    LinkAttr.DataType := DbDataType.Integer;
    LinkAttr.Id := "LinkAttr";
    LinkAttr.Name := Attribute to link;
    //Link with the dictionary
    Link := Dict.Links.Add;
    Link.Attribute := LinkAttr;
    Link.Reference := Dict2.Attributes.Key;
    Link.Id := "Link";
    Link.Name := Link with the dictionary Dict_2;
    //Imported attribute GUID
    LookupAttr := Attrs.Add;
    LookupAttr.Id := "Dict2_GUID";
    LookupAttr.Name := "GUID";
    LookupAttr.Link := Link;
    LookupAttr.Lookup := Dict2.Attributes.GUID;
    MObj.Save;
End Sub UserProc;

After executing the example the attribute used to link with the Dict_2 dictionary is created in the first dictionary. The link is established by the Key attribute, then the imported attribute that refers to the GUID attribute of the second dictionary is created in the first dictionary.

See also:

IRdsLinks