HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Configuring Dynamic Data Store (11.3-11.x)

This topic describes how to configure the Dynamic Data Store (11.3-11.x)

You have the following options to configure through the application’s configuration file:

The <episerver.dataStore> element has one child element called .

  • The element has the child elements and and the following attributes:
    • defaultProvider is the name of the Dynamic Data Store provider to use.
      The name should correspond to an element with the same name in the element.
    • autoResolveType can be true (default) or false.
      If set to true then the Dynamic Data Store tries to resolve .NET Types if the System.Type.GetType method call fails for types stored in a store. The resolution is done by first removing the version information from the type string and calling Type.GetType again. If this fails, then the assembly information is removed from the type string and Type.GetType is called again. If the Type still is not resolved, an exception is thrown.
      If this value is set to false, type resolving is done through assembly redirects in the configuration file.
    • autoRemapStores can be true (default) or false.
      If this is set to true, then the Dynamic Data Store automatically remaps all .NET classes decorated with the EPiServerDataStoreAttribute attribute and where the AutomaticallyRemapStore property is set to true, to their respective stores when the Class and store mappings are no longer aligned. If this value is set to false, no automatic remapping is done for any class.
  • The elements contains a child elements for each Dynamic Data Store provider available.
    Currently, only a providers for Microsoft SQL Server is available.
  • The element contains a single child element and the following attributes:
    • defaultProvider is the name of the Dynamic Data Store cache provider to use. The name should correspond to an element with the same name in the element.
  • The elements contain a child elements for each Dynamic Data Store cache provider available.
    Currently, providers are available for HTTP Runtime and Null (no caching).

Change configuration programmatically

It is also possible to modify some of the Dynamic Data Store configuration programmatically through the EPiServer.Data.Dynamic.DynamicDataStoreOptions class. This should be done during the configuration phase of the site initialization. This can be done by creating an initialization module that implements the IConfigurableModule interface and modify the options in the ConfigureContainer method.

[InitializableModule]
    [ModuleDependency(typeof(DataInitialization))]
    public class DynamicDataStoreConfiguration : IConfigurableModule
    {
        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            context.Services.Configure<DataStoreOptions>(o =>
            {
                o.AutoResolveTypes = false;
                o.AutoRemapStores = false;
            });
        }
    
        public void Initialize(InitializationEngine context) { }
        public void Uninitialize(InitializationEngine context) { }
    }

Recommendations

  • Create/obtain instances of the DynamicDataStore on the stack, use them and then discard them. Note that the Dynamic Data Store is not thread safe and if an instance is used and shared between multiple threads, it should be protected with thread-locking techniques.
  • Implement EPiServer.Data.IDynamicData or a Guid property called Id on your objects to be saved when you want to control the external identity of your objects.
  • Use the same instance of a Dynamic Data Store to load and then update a POCO object (object without identity).

See also: episerver.datastore


What’s Next
Did this page help you?