Get Started!


A DataItems property that references a set of DataItems Where "T" inherits from DataItem.

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

This references a List List<DataItem> of type T, see the DataItemRef for how to relate a single item.

Adding a DataItemsRef<T> property

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

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

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

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 aTags of type List<Tag> which references another property oTagsRef of type DataItemsRef<Tag>.

public List<Tag> aTags
  get { return oTagRefs.aDataItems; }
  set { oTagRefs.SetDataItems(this, value, "_CATEGORY"); }

The get simply returns the aDataItems property of the DataItemsRef. We add the get to make our external use of this DataType more legiable.

However, internally DataItemsRef<T>.aDataItems executes a query against the data server for the referenced item. If any matches are found the result is cached.

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

The SetDataItems method also records the sort / order of the items assigned, so when the get is referenced, the items returned are in the same sequence as they where when assigned.

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