Get Started!


A DataItem property that references an other DataItem Where "T" inherits from DataItem.

Canvas has a built-in relational property that allows you to link DataItems with each other via the DataItemRef property.

This references a single DataItem of type T, see the DataItemsRef for how to relate multipule items.

Add DataItemRef Property Dialog p-r

Adding a DataItemRef<T> property

To add a DataItemRef<T> to a given DataType, use the "Add Property" dialog & select the following value

  • Type - Special
  • Special Type - DataItemRef<TypeToRef>
  • Default Value - new DataItemRef<TypeToRef>()

Where TypeToRef is the Type which you are refering, for example Cat.

Note You need to include the Namespace via the Using field of the DataItem, found when you click "Toggle Settings" on the Edit DataItem screen.

Remember to Generate.

Properties & Methods

You could interact directly with this property in your code but we reccomend extending the DataItem, via the MyTypes/mytype-extend.cs file, with a get / set.

For example, the following defines a get & set for a property oCat of type Cat which references another property oCatRef of type DataItemRef<Cat>.

public Cat oCat
  get { return this.oCatRef.oDataItem; }
  set { this.oCatRef.SetDataItem(this, value, "_CATEGORY"); }

The get simply return the oDataItem property of the DataItemRef. We add the get to make our external use of this DataType more legiable.

However, internally DataItemRef<T>.oDataItem executes a query against the data server for the referenced item. If a match is found the result is cached.

The set updates the reference by invoking the SetDataItem method. The last param allows for a reverse look up, allowing you to reference the DataItem with this property via the Cat.

Note, the use of the [BsonIgnore] attribute, this stops the field being written to the MongoDB.