IStandardDimBlock.Where

Syntax

Where: IExpression;

Description

The Where property returns filter condition for all elements of table dictionary block.

Example

Executing the example requires that the repository contains a table dictionary with the TAB_DIM identifier. The dictionary list of attributes contains one additional attribute with the codes of parents. The repository also contains a table with the Tablica_1 identifier. The table has four fields: Id, Name, Ord and Parent_Id.

Sub Main;

Var

MB: IMetabase;

MObj: IMetabaseObject;

Dataset: IDatasetModel;

DatasetFields: IDatasetModelFields;

Dim: IStandardDimension;

DimBlocks: IStandardDimBlocks;

DimBlock: IStandardDimRecursiveBlock;

BlockAttr: IStandardDimAttributes;

PrimIndex: IStandardDimIndex;

s: String;

Begin

s := "Table_1";

MB := MetabaseClass.Active;

MObj := MB.ItemById("TAB_DIM").Edit;

Dataset := MB.ItemById(s).Bind As IDatasetModel;

DatasetFields := Dataset.Fields;

Dim := MObj As IStandardDimension;

DimBlocks := Dim.Blocks;

BlockAttr := Dim.Attributes;

DimBlock := DimBlocks.Add(DimBlockType.Recursive) As IStandardDimRecursiveBlock;

PrimIndex := DimBlock.Indexes.PrimaryIndex;

PrimIndex.Attributes.Add(Dim.Attributes.Id);

DimBlock.Dataset := Dataset;

//Attribute binding

DimBlock.Binding(BlockAttr.Id).AsString := s + "." + DatasetFields.FindById("Id").Id;

DimBlock.Binding(BlockAttr.Name).AsString := s + "." + DatasetFields.FindById("Name").Id;

DimBlock.Binding(BlockAttr.Order).AsString := s + "." + DatasetFields.FindById("Ord").Id;

DimBlock.Binding(BlockAttr.Item(BlockAttr.Count - 1)).AsString := s + "." + DatasetFields.FindById("Parent_Id").Id;

//Upper level

DimBlock.StartWith.AsString := s + "." + Dataset.Fields.FindById("Parent_Id").Id + "=0";

DimBlock.Where.AsString := "(" + s + "." + Dataset.Fields.FindById("Id").Id + ">=0)And(" + s + "." + Dataset.Fields.FindById("Id").Id + "<=30)";

//Connection adjustment is performed by the recursion index

DimBlock.ConnectByIndex := PrimIndex;

DimBlock.ConnectBy(PrimIndex.Attributes.Item(0)).AsString := s + "." + DatasetFields.FindById("Parent_Id").Id;

MObj.Save;

End Sub Main;

After executing the example a new recursive block is created in the dictionary. Block attributes are linked to the fields of data source, as well as the block recursion is adjusted. When a dictionary is created, elements of the upper level are elements with the Parent_Id value, equal to 0. Only elements with the field value Id in range 0-30 are displayed.

See also:

IStandardDimBlock