A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

smithsson68@gmail.com
Oct 16, 2009
  16954
(0 votes)

Introducing The Dynamic Data Store

Ok, so maybe “Introducing” was a bit optimistic in this case as the cat has been out of the bag for a few weeks on this subject.

The Dynamic Data Store is a new component which will be shipped with EPiServer CMS 6 but forms part of a framework we are building up here at EPiServer so it should also be available in the future with other EPiServer products such as EPiServer Community.

A typical conversation about the Dynamic Data Store normally goes something like this:

Fred: So what is the Dynamic Data Store?

Jim: It’s a store for storing dynamic data obviously!

Fred: Hmm, isn’t most data dynamic in some way?

Jim: Yeah I guess.

Fred: So what makes your store so special?

Jim: Well, the dynamic in Dynamic Data Store actually refers to the structure or shape of the data.

Fred: What are you talking about?

Jim: For example, storing data in a database using Entity Framework or NHibernate requires you to design and compile a class when developing your application. This works really well when you know the shape or structure of your data at compile time. EPiServer CMS has a few features where the shape or structure of the data isn’t actually known until runtime.

Fred: Examples please!

Jim: XForms and Page Types for starters!

Fred: Ok, so you’ve cracked the mind boggling problem of storing name/value pairs in a database. Congratulations!

Jim: Basically yes. Well….there is a bit more to it that than.

Fred: Go on.

Jim: We’ve sprinkled a little bit of magic powder on top of it.

Fred: Have you been drinking again?

Jim: That would be telling. Anyways….what I’m trying to say is that, yes, the Dynamic Data Store stores names/value pairs or property bags as we like to call them, BUT the magic is that they are treated exactly the same way internally as compile time objects.

Fred: Compile time objects?

Jim: .NET classes to you my friend. Actually to put it more correctly, compile time objects are treated exactly the same as property bags internally.

Fred: How many have you had?

Jim: One or two but the point is now we have a way of storing our dynamic data structures such as XForms in a relational database in relational form.

Fred: And that is good because?

Jim: Well, searching for one. For example, an XForm post suddenly becomes a first class artifact in the EPiServer CMS database. Think of all the useful reports and queries you could do with them.

Jim: Then there’s LINQ support.

Fred: LINQ?

Jim: Yeah you know, Language INtegrated Query. With the Dynamic Data Store you can can make queries against property bags using LINQ.

Fred: Sounds interesting. If I wanted, could I store my own data in the Dynamic Data Store?

Jim: Yes you can my friend. Both dynamic / property bags / name-value pairs (whatever you want to call them) and normal .NET class instances can be saved in the Dynamic Data Store.

Fred: Sounds like a configuration nightmare. I bet there are 50 XML files to edit every time you want to save a new type right?

Jim: Nope. It’s a code only solution. No XML files (web.config apart), just create your property bag or .NET class instance at runtime, create a store and save.

Fred: Got any code examples?

Jim: Sure. Here’s how you save a property bag:

using EPiServer.Data;
using EPiServer.Data.Dynamic;
PropertyBag pb = new PropertyBag();
pb.Add("FirstName", "Jack");
pb.Add("LastName", "Williams");
pb.Add("DateOfBirth", new DateTime(1973, 05, 25));
pb.Add("Gender", 'm');

DynamicDataStore store = DynamicDataStore.CreateStore("People", true, pb.GenerateTypeBag());
Identity id = store.Save(pb);

Fred: How about reading it back?

Jim: There are 3 ways. Directly by the Id returned from the Save method:

PropertyBag pb2 = store.Load(id);

or using Find:

var propertyBags = store.Find("FirstName", "Jack");

or using LINQ

var propertyBags = from pb in store where pb["FirstName"] == "Jack" select pb;

Fred: Cool. Can I do more complex stuff with the LINQ support?

Jim: What like:

var propertyBags = from pb in store
                   where 
                   ((DateTime)pb["DateOfBirth"]) > new DateTime(1976, 01, 01) &&
                   ((string)pb["Gender"]) == "m"                               
                   select pb;

Fred: Yeah

Jim: Nah!

Fred: What?

Jim: Just kidding. Actually the LINQ support is quite extensive. In many cases better than a well know LINQ toolkit you can download from CodePlex.

Fred: Ok, you said I could also store normal .NET class instances in it like I can with Entity Framework or NHibernate.

Jim: Sure. Like this:

Person p = new Person()
{
  FirstName = "Jack",
  LastName = "Williams",
  DateOfBirth = new DateTime(1973, 05, 25)
};

DynamicDataStore<Person> store = DynamicDataStore<Person>.CreateStore("People", true);
Identity id = store.Save(p);

So there you go. That’s the introduction to the Dynamic Data Store or DDS as we call it internally. I will post more detailed information over the coming days and weeks.

Code samples can be found here and documentation here

Have fun!

Oct 16, 2009

Comments

Please login to comment.
Latest blogs
A day in the life of an Optimizely OMVP: Learning Optimizely Just Got Easier: Introducing the Optimizely Learning Centre

On the back of my last post about the Opti Graph Learning Centre, I am now happy to announce a revamped interactive learning platform that makes...

Graham Carr | Jan 31, 2026

Scheduled job for deleting content types and all related content

In my previous blog post which was about getting an overview of your sites content https://world.optimizely.com/blogs/Per-Nergard/Dates/2026/1/sche...

Per Nergård (MVP) | Jan 30, 2026

Working With Applications in Optimizely CMS 13

💡 Note:  The following content has been written based on Optimizely CMS 13 Preview 2 and may not accurately reflect the final release version. As...

Mark Stott | Jan 30, 2026

Experimentation at Speed Using Optimizely Opal and Web Experimentation

If you are working in experimentation, you will know that speed matters. The quicker you can go from idea to implementation, the faster you can...

Minesh Shah (Netcel) | Jan 30, 2026