smithsson68@gmail.com
Jun 8, 2010
  7788
(1 votes)

Storing EPiServer CMS Properties in the Dynamic Data Store

I had the pleasure of talking to Anders Hattestad, one of our esteemed EMVP’s, when I was at the EPiServer Partner Summit 2010.

One of the things he raised was why the Dynamic Data Store didn’t have built-in support to store EPiServer CMS Properties in their native CLR data type: E.g. A PropertyBoolean should be stored ‘inline’ as a boolean and not as a reference object.

There are 2 reasons for this:

  1. The Dynamic Data Store is part of the EPiServer Framework which is completely independent of CMS and therefore contains no references to any CMS assemblies.
  2. We screwed up! Yes, you heard me. We should of course have added this functionality to the CMS 6.0 code.

To remedy this situation ‘tout de suite’ I have written a few classes that can be downloaded and added to your EPiServer CMS solutions.

The classes implement the EPiServer.Data.Dynamic.ITypeHandler interface which allows exactly for this type of scenario: To map a property of a class which is in itself a class and would normally be stored as a reference type to an inline data type. Inline data types are those that can be mapped directly to SQL Server / Oracle columns (integers, floating point numbers, strings, dates, Guids, booleans, byte arrays).

CmsPropertyDdsTypeHandler Class

This maps the core CMS PropertyData derived classes to their inline CLR equivalents (PropertyString to String, PropertyDate to DateTime etc). Feel free to add your own properties in here but bear in mind that they must map to one of the CLR Types that the DDS defines as inline. See the “Inline” section in the Dynamic Data Store Documentation on EPiServer World.

DdsTypeHandler Class

This a generic class that gives the ability to specify a mapping from one Type to another. For example to specify that a PageReference instance should be stored as a string in the DDS:

   1:  new DdsTypeHandler<PageReference, string>(
   2:  (value) =>
   3:  {
   4:       return value.ToString();
   5:  },
   6:  (value) =>
   7:  {
   8:        return PageReference.Parse(value);
   9:  });

DdsInitialization

This is an example initialization module that creates an instance of the CmsPropertyDdsTypeHandler class and also registers a handler for PageReference using the DdsTypeHandler class. The class also has placeholder methods for creating and remapping stores which you may find useful. I will blog more about these subjects in the future. You can read more about initialization modules in the Initialization Documentation on EPiServer World.

The example classes can be download here.

Jun 08, 2010

Comments

Sep 21, 2010 10:33 AM

Cool, but actually the dynamic datastore do handle PageReference as an inline type :)
But the same thing here is easy to use with PropertyPageReference or other stuff.. Thanks a lot, and looking forward to check this more out.
/ Anders Hattestad

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024