Skip to content

object properties

vijay@envivo edited this page Oct 21, 2023 · 8 revisions

Object Properties

These properties contain references to other objects. The UI allows the property to accept another object, but only if the property accepts the object type.

Declaring the type of relationship is important at this stage, as it describes lifetimes between objects. This is especially important when designing Aggregate Roots.

Consider two objects, A and B. The relationship type may be defined as:

Relationship Description
Has (aka "Aggregation") Object A is linked to B.
If A is removed, B remains intact.
Owns (aka "Composition") Object A owns B.
If A is removed, B would no longer exist.
Owned By (aka "Parent") Object A is owned by B.
Needed for bidirectional references between the objects

In code, these relationships are declared using the Relationship attribute, like so:

[Relationship(RelationshipType.Has)] //👈
public Product Product { get; set; }

Setting properties using the UI

The Relationship Type drives how you interact with properties:

"Owns" relationship

Only new objects can be assigned to the property (objects can only have one owner, and the property's parent is the owner). In the UI, use the Create option on the property:

"Has" relationship

Only existing objects can be assigned to the property (as those objects are typically owned by another parent). In the UI, use the Link with option on the property:

The UI only allows a selection from an existing set of objects, so you need to declare the query that will provide that set. See the Queries and Filters section for more information.

"Owned By" relationship

This property cannot be set by the UI. Typically this property is set within code, and merely displayed in the UI for navigation purposes:

💡 Developer Tips

  • When adding a reference to an Aggregate Root, you may need an intermediary Aggregate Reference. See the Aggregate References section for more information.

Clone this wiki locally