We have moved!

You are currently looking at documentation for Umbraco 8 and older versions.
An automated guess is that docs.umbraco.com/umbraco-cms/reference/management/models/datatype could be the link to the new documentation for Umbraco 9 and newer versions.

    DataType

    A DataType is what you see in the backoffice in the Settings / DataTypes tree. The listed nodes are definitions of the DataTypes that are available to use on your PropertyTypes.

    • Namespace: Umbraco.Core.Models
    • Assembly: Umbraco.Core.dll

    All samples in this document will require references to the following dll:

    • Umbraco.Core.dll

    All samples in this document will require the following using statement:

    using Umbraco.Core.Models;
    

    Constructors

    new DataType(IDataEditor editor, int parentId = -1)

    Constructor for creating a new DataType object where the necessary parameter is a IDataEditor. Optionally, the parentId can be added, if not provided the default value is -1, which means it will be created at root level.

    Properties

    .CreateDate

    Gets or Sets a DateTime object, indicating then the given DataType was created.

    .CreatorId

    Gets or Sets the Id of the User who created the DataType.

    .DatabaseType

    Gets or Sets the DatabaseType as a DataTypeDatabaseType enum for which the DataType's value is saved as.

    .Id

    Returns the unique DataType Id as a Int, this ID is based on a Database identity field, and is therefore not safe to reference in code which are moved between different instances, use Key instead.

    .Key

    Returns the Guid assigned to the DataType during creation. This value is unique, and should never change, even if the DataType is moved between instances.

    .Level

    Gets or Sets the given DataType level in the site hierarchy as an Int. DataType placed at the root of the site, will return 1, DataType right underneath will return 2, and so on.

    .Name

    Gets or Sets the name of the DataType as a String.

    .ParentId

    Gets or Sets the parent DataType Id as an Int.

    .Path

    Gets or Sets the path of the DataType as a String. This string contains a comma separated list of the ancestor Ids including the current contents own id at the end of the string.

    .SortOrder

    Returns the given DataType index, compared to sibling DataType.

    .Trashed

    Returns a Bool indicating whether the given DataType is currently in the recycle bin.