The entitySelection.toCollection( ) method creates and returns a collection where each element is an object containing a set of properties and values corresponding to the attribute names and values for the entity selection.
If the filter parameter is omitted or contains an empty string or "*", all the attributes are extracted. Attributes with "kind" property as "relatedEntity" are extracted with the simple form: an object with property __KEY (primary key). Attributes with "kind" property as "relatedEntities" are not extracted.
In the filter parameter, you can pass the entity attributes to extract. Two syntaxes are allowed:
a string with property paths separated with commas: "propertyPath1, propertyPath2, ...".
a collection of strings: ["propertyPath1","propertyPath2",...]
If filter is specified for attributes of the relatedEntity kind:
propertyPath = "relatedEntity" -> it is extracted with simple form
propertyPath = "relatedEntity.*" -> all the properties are extracted
propertyPath = "relatedEntity.propertyName1, relatedEntity.propertyName2, ..." -> only those properties are extracted
If filter is specified for attributes of the relatedEntities kind:
propertyPath = "relatedEntities.*" -> all the properties are extracted
propertyPath = "relatedEntities.propertyName1, relatedEntities.propertyName2, ..." -> only those properties are extracted
In the options parameter, you can pass the dk with primary key and/or dk with stamp selector(s) to add the entity's primary keys and/or stamps in extracted objects.
The begin parameter allows you to indicate the starting index of the entities to extract. You can pass any value between 0 and entity selection length-1.
The howMany parameter lets you specify the number of entities to extract, starting with the one specified in begin. Dropped entities are not returned but are taken into account according to howMany. For example, if howMany= 3 and there is 1 dropped entity, only 2 entities are extracted.
If howMany > length of the entity selection, the method returns (length - begin) objects.
An empty collection is returned if:
the entity selection is empty, or
begin is greater than the length of the entity selection.