An array can be either an independent item of the model (then it has a name and it will be displayed in the root of the model), or a child item of some other object.
An array is defined by the Array
type (or LazyArray
for
"lazy" array) in the descriptor (the first field) of the dataset.
It's simply a recordset. Each row in the set will be a corresponding object of array. The type of the object is determined by the set descriptor.
Let there be a fragment of SQL code:
It will form the
Agents
. array at the root of the model. Each item of the array will be of
TAgent
type with the following properties: Id
, Name
, Code
.
A child array is always nested and is a property of another object. Usually has no name. The parent must have a
null
placeholder property with the item type of the child array. Please note that the child set must
be processed after the basic one.
In order to associate an array with a parent object, the recordset must contain a field with a link to the parent
object in the form [Name!ParentType.PropertyName!ParentId]
, where
Binding works as follows:
!ParentId
field is taken.ParentType
type with the corresponding identifier is searched for in the
model (it goes without saying that this identifier should be marked with the !Id
modifier).
PropertyName
name is searched for in the found object. The item is added
to the array corresponding to this field.Let there be a fragment of SQL code:
It will form the
Document
object of the TDocument
ype at the root with the following properties:
Id
, Date
, Rows
. The Rows
property will be the items array of the
TRow
type with the following properties: Id
, Qty
, Price
, Sum
.
Lazy (on demand) arrays are not added to the model in the process, but are loaded the first time the property is accessed. Most often, this mechanism is used when the basic model is an array, and the child arrays are not always needed, but only on the attempt to display them. A typical example is a list of contractors, each of which contains the documents associated with it.
Lazy arrays can only be children and are defined by the LazyArray
modifier.
To load the lazy array, the model load stored procedure will be called with a suffix corresponding to the property name of the
main model. The ID of the main item will be passed to it as the @Id
parameter. It should return a set that corresponds
to the description of the array in the main model. The property with the !ParentId
modifier is optional.
Let there be a list of the contractors with a list of documents.
It will form the
Document
object of the TDocument
ype at the root with the following properties:
Id
, Date
, Rows
. The Rows
type will be the items array of the
TRow
with the following properties: Id
, Qty
, Price
, Sum
.
Lazy array loading procedures can also take parameters and use pagination.