Object type configuration
Object type information refers to the metadata of Xperience object types. The information determines the basic properties and behavior of an object type when:
- Performing basic CRUD operations over objects of a particular type
- Evaluating relationships with other classes (parent-child, object references and bindings)
- Evaluating object dependencies (e.g,, to perform automatic deletion of related objects)
The configuration also determines how other system features that support working with object types behave:
Object types store their configuration in a separate type – ObjectTypeInfo
– which is a mandatory component of each generated Info class, together with the following:
- A unique object type name as an identifier (generated Info classes store the value in a constant named
OBJECT_TYPE
). - The
RegisterObjectType
assembly attribute. The attribute assigns the type information definition to the Info class via the unique object type name.
Type info properties
ObjectTypeInfo constructor
Navigate to the TYPEINFO
field in the Info class’s code and configure the following parameters in the ObjectTypeInfo
constructor according to your requirements:
Parameter | Type | Description |
Object type metadata | ||
providerType | string | The Type of the class’s InfoProvider class. For example: |
objectType | string | Defined in the code of the Info class (typically in an |
objectClassName | string | The code name assigned to the class in the Xperience administration. Identifies the class’s definition in the database. For example, use the class code name when writing SQL where conditions for loading and filtering class records. objectType and objectClassName identifiers For custom object types, always use the same identifier for both the class and the object type (the default for generated Info classes). Two distinct identifiers are in rare cased used internally by the system for purposes beyond the scope of this document. |
Database-related configuration | ||
idColumn | string | Column that stores the IDs of objects of the given type (a primary key column). Populated by the code generator if set on the object’s Code tab in the administration. |
timeStampColumn | string | Column that stores the last modification date for objects. Can be |
guidColumn | string | Column that stores the GUID identifiers of objects. Can be |
codeNameColumn | string | Column that stores the unique text identifiers of objects. Can be |
displayNameColumn | string | Column that stores the visible names of objects (names used in the administration interface or on the live site). Can be |
binaryColumn | string | Column that stores any binary data related this type of objects. Can be |
Object type relationships | ||
parentIDColumn | string | the name of the class field that stores the IDs of parent objects. Set to |
parentObjectType | string | the object type name of the class’s parent (as defined in the type information of the parent class). Set to |
ObjectTypeInfo properties
Use the initializer to set other properties for the object. See Reference - ObjectTypeInfo for more information about the available properties.
Hashtable caching
Info classes of object types support caching over columns that can be used to uniquely identify individual records (ID, Code name, GUID). Items get cached the first time they are fetched from the database. For subsequent queries targeting previously retrieved records, the cached values are used, reducing database usage. However, note that enabling hashtable caching for object types with a significant number of records may result in a large increase in application memory usage.
The caching is enabled by placing the InfoCache
attribute over the generated info class.
using CMS.DataEngine;
// Enables caching over the object ID and code name
// Note that the code name and guid columns must also be set using the ObjectTypeInfo constructor
[InfoCache(InfoCacheBy.ID | InfoCacheBy.Name | InfoCacheBy.Guid)]
public partial class MyObjectTypeInfo : AbstractInfo<MyObjectTypeInfo, IMyObjectTypeInfoProvider>
{
}
Code generator support
The caching is also configurable via each object type’s Code tab in the administration. Columns usable as unique identifiers have the Use hashtable option available. The code generator reflects this setting when generating the code file by decorating the Info class with the InfoCache
attribute using corresponding parameters. See Configure code generation for data classes.
The attribute also allows you to configure the caching behavior via the following optional properties:
- Cache priority (
Priority
) – Determines whether cached items can be released to relieve memory pressure. Set using theInfoCachePriorty
enum. Allowed by default. - Eager loading (
LoadEagerly
) – Loads all objects of the given type into the cache on application start. Note that eagerly loading objects with a lot of records consumes large amounts of application memory. Disabled by default.
Additional options
You can use the type information to configure how object types behave in the system. See the following topics:
- Enable CI/CD for object types – configure the type information of your custom classes to support synchronization of data using CI/CD.
- Model object type relationships – define relationships among object types that are enforced by the system’s ORM framework:
- Parent-child – use the type information to define a hierarchy for the classes representing your module’s data. Setting parent-child relationships for classes ensures that the system can provide many types of automatic behavior.
- One-to-many and many-to-many relationships – define fields for your custom classes that store references (foreign keys) to objects of other classes and vice versa.
- Reference - ObjectTypeInfo – provides a reference of the
ObjectTypeInfo
properties that you can use to define object type behavior in the system.