Identity, date, and time
Describes managing identities, dates and times.
Identity management
Each data structure saved in the Optimizely Dynamic Data Store (DDS) is given an identity. This identity is represented by the EPiServer.Data.Identity
class, which contains the following parts:
System.Guid
, an External ID supplied by the user of the DDS or generated dynamically.System.Int64
, a Store ID generated by the store.
Specific identity management
The implementer of a .NET class stored in the DDS can choose to manage the ID the objects get when stored explicitly. This can be done in the following ways:
- Implement the
EPiServer.Data.Dynamic.IDynamicData
interface. - Implement the
EPiServer.Data.Entity.IEntity
interface. - Implement a property called ID of the type
System.Guid
.
See the UsingManagedIdentity
class in the DDS sample project for examples of specific identity management.
Implicit identity management (POCO support)
The DDS supports POCO objects. When POCO objects are stored in the DDS, special care needs to be taken when saving (updating) existing objects. Because the DDS does not have an ID it can use to determine if an object is new or existing, it relies on state information held for objects previously loaded through the same instance of the DDS when saving them back.
See the UsingImplicitidentity
class in the DDS sample project for examples of implicit identity management.
Date and time management
By default, dates are stored as unspecified, which means the data class is responsible for converting to local or UTC time.
You can change this behavior by using the EPiServerDataStoreAttribute
, for example: [EPiServerDataStore(DatabaseDateTimeKind = DatabaseDateTimeKind.Utc)]
. When this is activated, dates and times are automatically converted when loading and saving. The actual date and time stored in the database are used when using LINQ, and no automatic conversion occurs. See also Store UTC date and time in the database (Legacy).
Updated 6 months ago