Skip to content

Arrays and Collections

Erik W edited this page Apr 11, 2016 · 4 revisions

Arrays

If a property stores a comma separated list of primitive data type values, Vault directly supports arrays of all primitive C# data types. (int, long, string, etc.).

Any property editor that supports the creation of a CSV property maps well to array values. For example:

  • Dropdownlist Multiple (DDLM Publish Keys too)
  • Checkboxlist
  • Multinode Tree Picker

Example:

The following C# class would map to these properties:

Array Property Editor

[UmbracoEntity(AutoMap = true)]
public class ArraysViewModel
{
    /// <summary>
    /// Raw integer arrays are supported using a textstring
    /// </summary>
    public int[] IntArray { get; set; }

    /// <summary>
    /// Raw string arrays are supported using a textstring
    /// </summary>
    public string[] StringArray { get; set; }
         
    /// <summary>
    /// List of Integers that correspond to prevalues in the Umbraco DB. 
    /// Lookup is required to get text values.
    /// </summary>
    public int[] DropDownListMultiplePublishKeys { get; set; }
        
    /// <summary>
    /// List of dropdown values. Publishes the string entry so no lookup is required
    /// </summary>
    public string[] DropDownListMultiple { get; set; }
        
    /// <summary>
    /// This contains the list of Dictionary Picker values
    /// </summary>
    public string[] DictionaryPicker { get; set; }

}

###Collections and Lists

Vault expects IEnumerable<T> and IList<T> in models to have T be a C# class view model that is decorated with UmbracoVault.Attributes.UmbracoEntity, and will use Umbraco node IDs to populate these.

Example

For this MultiNode Treepicker backed property, set to store "Data as CSV", the following object would map to it:

Array Property Editor

[UmbracoEntity(AutoMap = true)]
public class ObjectArraysViewModel 
{
    /// <summary>
    /// Generic content lists are supported.
    /// </summary>
    public IList<StaffMember> StaffList { get; set; }
}
Other Vault Extensions:
Clone this wiki locally