IStandardDimRecursiveBlock.StartWithWhere

Syntax

StartWithWhere: IExpression;

Description

The StartWithWhere property returns an object containing a condition to filter elements of the first dictionary level. This property is available only through Fore.

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 := "Tablica_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.StartWithWhere.AsString := "(" + s + "." + Dataset.Fields.FindById("Id").Id + ">=0)And(" + s + "." + Dataset.Fields.FindById("Id").Id + "<=10)";

//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. While creating a dictionary, the elements of upper level are elements with value of the Parent_Id field, equal to zero, these elements are also filtered by field values Id. Only elements in range 0-10 are displayed.

See also:

IStandardDimRecursiveBlock