Dictionary values are found by their key value and column name. To support both strongly typed references to dictionaries and columns as well as flexible references where the choice of dictionary and column is done at runtime, there are two different ways to retrieve values from dictionaries.
Strongly typed dictionary reference
Strongly typed references to dictionaries are preferable when you know in advance which dictionary and which column to read values from. When the rule or formula is written, Combinum checks that the dictionary and column exist and creates a reference that is not affected by future name changes. Another advantage with strongly typed references is that Combinum determines its return type so that for example a double value can be used in a mathematical expression directly without type conversion.
A strongly typed dictionary reference is written as Dictionary[Key; Column].
Example
City[SelectedCity; City.Latitude]
Looks up the latitude of a city in a dictionary (table) based on the variable SelectedCity.
Dictionary reference that is interpreted at runtime
Sometimes, which dictionary and column the data should be read from may need to be controlled by the product configuration. For example, the choice of energy efficiency class may control which column the efficiency of an electric motor should be read from. In these types of situations, a loose coupling is needed where the dictionary and column are determined at runtime.
A runtime reference created using the function Dictionary().
Example
Dictionary("City"; SelectedCity; "Latitude")
Looks up the latitude of a city in a dictionary (table) based on the variable SelectedCity.
Note! The Dictionary() function always returns the value as a string even if it is numeric. So to use such a value in a mathematical expression, a type conversion is required using one of the ToDouble() or ToInt() methods.