Skip to main content
Creating a contact through an entity can be done in two 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 create a new contact as explained in this example. The difference is that we do not save the created contact. Instead, we assign it to another entity such as the Person entity and then save the Person:
CS

Example 2

Below is the example of creating a Contact entity, which is a property of another entity, such as Person.
CS
The difference between example 1 and example 2 is that here the properties of the Contact entity are accessed through the instance of the Person entity as shown below. However, the statements may vary a little depending on the data type.
CS
When saving the Person entity with the use of the Save method the new Contact is also saved NestedPersistent).
When using the above type of code, the main entity (such as the Person entity above) should also be created. When retrieving a person, it may already have a contact assigned to it. So therefore when adding values to the properties of the Contact in such an entity, what we would actually be doing is updating the existing Contact information.