New from Eco5 is the ability to handle tuples. Tuple is fancy word for something “taped together from bits and pieces of other stuff”. This is very useful when it comes to build result sets that is not necessary something that exists in your model. Like sums or collecting name and address together even if they are stored in different classes.
Tuples are what an sql server return when you omit the “*” and write explicit stuff in the select part. In fact the columns in the select part is the tuple-definition as far as the sql server is concerned.
In Eco 5 OCL operators create tuples: GroupBy and Collect.
Consider this model:
I want to GroupBy the contents of Class3.Attribute1;
IElement elem = ocl.Evaluate("Class1.allinstances.class2.class3->groupby(x|x.Attribute1)");
So what do I get back? A Tuple (don’t you just hate rhetoric questions? (I don’t))!
The tuple consists of a type with a generated name and specific properties. The properties are: Attribute1 and List.
The code below shows how to access the tuple result in code:
If I had grouped in more stuff, my tuple would have more properties.
If my tuple property is not an existing “thing” from my model but a tuple in itself it will be named part1 (if I another one, part2 etc).