Skip to main content
Creating an appointment through an entity can be done in 2 different ways:
  • If you create an entity called A and assign it to an entity called B, when saving B - entity A will be saved through NestedPersistent
  • you can create an entity that is a property of another entity. Then when saving the main entity, the entity created as the property of it will be saved as well.
Both these would give the same results.

Example 1

CS
In the example above, we have created an appointment as explained in this example. The difference is that here we do not save the created appointment. Instead, we assign it to the Appointments property of the Contact instance created and then save the Contact:
CS

Example 2

Below is an example of how we may use the AddNew method available in the Appointments property of the Contact class to create a new appointment.
CS
The difference between example 1 and example 2 is that here we have created an instance of the Appointment to be added to the Appointments collection and by indexing through the collection we have assigned the desired values for the specific appointment as shown below.
CS
The Appointment created will be saved when saving the Contact entity with the use of its Save method.
When adding an appointment by indexing through the Appointment collection of any entity, you should take caution to identify and add to the newly created Appointment, without updating an earlier Appointment.For instance, in example 2 if there was an appointment already existing in Appointment[0] location when you assigned values to properties what actually would happen is an update instead of an insert since the values that already exist in the 0th location will be modified.