Create Datatypes

Creating Data Types Programmatically

You create a data type programmatically by creating a corresponding interface inherited from IData. You should specify a number of type attributes for the interface as well as add a number of properties with a number of property attributes.


using System;
using Composite.Data;

namespace Demo
    public interface IMyUser : IData
        Guid Id { get; set; }

        [StoreFieldType(PhysicalStoreFieldType.String, 64)]
        string Name { get; set; }

        [StoreFieldType(PhysicalStoreFieldType.String, 64)]
        string Email { get; set; }

Download the source

In the sample:

  • The ImmutableTypeId attribute specifies a unique ID for the type.
  • The KeyPropertyName attribute specifies the name of the key property used as a key for the data type.
  • The DataScope attribute specifies data scopes items of the data types should exist in (DataScopeIdentifier.Public and DataScopeIdentifier.Administrated).
  • The AutoUpdate attribute has C1 CMS automatically add and update your type.
  • The ImmutableFieldId attribute specifies a unique ID for the property.
  • The StoreFieldType specifies the underlying type of the property.

Please also see: