Contact Entity has a property called Persons, which is a Collection of Person Entities. In other words, the Contact.Persons property is of type PersonCollection
There are two major types of Collections: Collection of Entity types and Collection of Row types.
Entities and their relevant collections
Create
Contact Entity and assign values to some of its properties.
Persons is a property of the Contact Entity of type PersonCollection (a collection of Person Entities). Similarly, AppointmentCollection is a collection of Appointment Entities.
In the example, we create a new Appointment Entity and assign values to some of its basic properties just as we did with the Person Entity.
Then we create a link between the appointment and the person.
The Person Entity can contain properties of Entities Collection type, Appointments is one such property. Hence, we can add the newly created Appointment to the Appointments property of the Person Entity.
Alternatively:
Contact Entity is saved, a new row will be added to the contact table in the database. New rows will also be added to the appointment and person tables, which will be linked to the entry in the Contact table by the contact_id field in each table. This cascade of events happens when we call Save().
Retrieve elements from a Collection of Entity types
To retrieve elements of a Collection, we can use theGetFromIdx function.
GetFromIdxFirstname() to retrieve a Collection of Person Entities with Firstname like “Linda”.
Delete
Using theDelete method, it is possible to delete an Entity collection. However, the relevant data contained in it will not be deleted from the database. Only the references that link the Entity to the Entity Collection will be deleted.
Here we delete the references to the Entities of an Entity Collection.
Deleting Rows vs. an Entity Collection
Rows, which consist of Row types, are another type that can be a property of an Entity. Therefore, it is possible to use theDelete method to delete such a set of Rows. The difference is that when Rows are deleted, it is removed from the database, whereas when an Entity Collection is deleted it is not.