HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Manage identity, date, and time

Control how the Dynamic Data Store assigns identity to stored objects and handles date and time conversions.

The Dynamic Data Store (DDS) assigns an identity to each stored data structure and provides options for managing date and time conversions. Understanding these behaviors helps ensure accurate data handling.

Manage identity

The DDS assigns an identity to each stored data structure. The EPiServer.Data.Identity class represents this identity and contains the following parts:

  • System.Guid – An external ID supplied by the DDS user or generated dynamically.
  • System.Int64 – A store ID generated by the store.

Manage specific identity

The implementer of a .NET class stored in the DDS controls the ID that objects receive when stored. To manage identity explicitly, use one of the following approaches:

  1. Implement the EPiServer.Data.Dynamic.IDynamicData interface.
  2. Implement the EPiServer.Data.Entity.IEntity interface.
  3. Implement a property called ID of the type System.Guid.

Manage implicit identity (POCO support)

The DDS supports POCO objects. When storing POCO objects, take special care when saving (updating) existing objects. The DDS does not have an ID to determine whether an object is new or existing. Instead, the DDS relies on state information from objects previously loaded through the same DDS instance.

Manage date and time

By default, the DDS stores dates as unspecified. The data class is responsible for converting to local or UTC time.

To change this behavior, use the EPiServerDataStoreAttribute. For example: [EPiServerDataStore(DatabaseDateTimeKind = DatabaseDateTimeKind.Utc)]. When activated, the DDS automatically converts dates and times during loading and saving. LINQ queries use the actual date and time stored in the database without automatic conversion. See also Store UTC date and time in the database (Legacy).