Persist AdomdDataProvider
The implementation demonstrated in this article can also be reviewed in the Persist AdomdDataProvider SDK Example of the SDK Examples Browser
In this article we will show you how to persist the current state of AdomdDataProvider via Telerik's RadPersistenceFramework.
Persistence Framework
In this article we will show you how to serialize and deserialize AdomdDataProvider and all of its settings via RadPersistenceFramework. You can use this feature to save the current state of the provider and load it next time the application is started.
Persist AdomdDataProvider
We've added the DataContract attribute to all classes used by AdomdDataProvider. So you can easily serialize it by using DataContractSerializer.
So lets create a simple class that we'll use to save and load DataProviderSettings. You have to add the DataContract attribute to the new class and DataMember attribute for its properties.
The next step is to create a new class, which implements Telerik.Windows.Persistence.Services.IValueProvider. IValueProvider has two methods that you will have to implement - ProvideValue and RestoreValue. The first one is used when the data is saved. The second one is used when the data is restored from a previously saved state. When saving the provider, you have to create an instance of DataProviderSettings class and set all of the properties. After that you can save the instance to a file or a stream. When using DataContractSerializer you have to give a collection of KnownTypes to the serializer. That's why we've created a new PivotSerializationHelper class which has a static member - KnownTypes. It consits of all types you'll need in order to serialize AdomdDataProvider. Here's an example how to implement it:
So the last step is to register a persistence provider and implement the logic to save and load the state of AdomdDataProvider: