Customization of the data provider allows you to implement your own database connector.
Custom data providers are not intended for accessing non-Microsoft SQL Server database engines. They only allow you to modify how queries are executed against the Microsoft SQL Server.
Customizing live site projects
Deploy the assembly containing the custom provider to your live site application, in addition to the Xperience administration application. This ensures that the customization applies when loading or modifying data in the live site application.
The recommended approach is to create and register a custom implementation of the IDataProvider interface.
using CMS;
using CMS.Core;
using CMS.DataEngine;
using CMS.DataProviderSQL;
// Registers the custom implementation of IDataProvider
// Set the 'Lifestyle.Transient' lifetime when registering the IDataProvider implementation
[assembly: RegisterImplementation(typeof(IDataProvider), typeof(CustomDataProvider), Lifestyle = Lifestyle.Transient)]
public class CustomDataProvider : IDataProvider
{
public IDataConnection GetNewConnection(string connectionString)
{
...
}
}You can create a custom data provide assembly and register it via the CMSDataProviderAssembly web.config key.
Open your administration solution in Visual Studio.
Add a new Class Library project to the solution, for example named CustomDataProvider.
Add the Xperience API libraries to the new project:
Reference the CustomDataProvider project from the Xperience web project (CMSApp).
Open your Xperience program files directory (by default C:\Program Files\Kentico\<version>) and expand the CodeSamples\CustomizationSamples\CustomDataProvider subfolder.
Copy the following files into the CustomDataProvider directory in your web project:
Include the new files into the CustomDataProvider project in Visual Studio:
Edit the copied files and rename the namespaces to exactly match the assembly name of your custom project (CustomDataProvider in this example).
Rebuild the solution.
The CustomDataProvider project is now integrated into your application. By default, the classes in the custom data provider are identical to the ones used by default, but you can modify them according to your own requirements.
Edit your application's web.config file.
Add the following key to the configuration/appSettings section:
<add key="CMSDataProviderAssembly" value="CustomDataProvider"/>The system loads the DataProvider class from the assembly specified as the value of the CMSDataProviderAssembly key.
Your application now uses the custom data provider for handling of database operations.