Contains(Attribute: IRdsAttribute): Boolean;
Contains[Attribute: Prognoz.Platform.Interop.Rds.IRdsAttribute]: boolean;
Attribute. MDM dictionary attribute, for which we define if it is included into unique key.
The Contains property determines whether the specified attribute is included into unique key of the MDM dictionary.
Available values:
True. Attribute is included into unique key.
False. An attribute is not included in a unique key.
Executing the example requires an MDM repository with the RDS_REPO identifier that contains an MDM dictionary with the RDS_DICT identifier.
Add links to the Metabase, Rds, Dal system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Dict: IRdsDictionary;
Attrs: IRdsAttributes;
Attr: IRdsAttribute;
UniqKeys: IRdsUniqueKeys;
UniqKey: IRdsUniqueKey;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemByIdNamespace("RDS_DICT", MB.ItemById("RDS_REPO").Key).Edit;
Dict := MObj As IRdsDictionary;
// Create a new attribute
Attrs := Dict.Attributes;
UniqKeys := Dict.UniqueKeys;
Attr := Attrs.Add;
Attr.DataType := DbDataType.String;
Attr.Name := "State number";
// Create the unique key
UniqKey := UniqKeys.Add;
UniqKey.Name := "Unique key by state number";
UniqKey.Contains(Attr) := True;
// Check if elements' values are unique
UniqKey.Check;
// Save changes
(UniqKey.Dictionary As IMetabaseObject).Save;
End Sub UserProc;
After executing the example a custom attribute is created in the MDM dictionary. A unique key of MDM dictionary is created by this attribute.
Executing the example requires an MDM repository with the RDS_REPO identifier that contains an MDM dictionary with the RDS_DICT identifier.
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Rds
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Dict: IRdsDictionary;
Attrs: IRdsAttributes;
Attr: IRdsAttribute;
UniqKeys: IRdsUniqueKeys;
UniqKey: IRdsUniqueKey;
Begin
MB := Params.Metabase;
MObj := MB.ItemByIdNamespace["RDS_DICT", MB.ItemById["RDS_REPO"].Key].Edit();
Dict := MObj As IRdsDictionary;
// Create a new attribute
Attrs := Dict.Attributes;
UniqKeys := Dict.UniqueKeys;
Attr := Attrs.Add();
Attr.DataType := DbDataType.ddtString;
Attr.Name := "State number";
// Create the unique key
UniqKey := UniqKeys.Add();
UniqKey.Name := "Unique key by state number";
UniqKey.Contains[Attr] := True;
// Check if elements' values are unique
UniqKey.Check();
// Save changes
(UniqKey.Dictionary As IMetabaseObject).Save();
End Sub;
After executing the example a custom attribute is created in the MDM dictionary. A unique key of MDM dictionary is created by this attribute.
See also: