/ dataproviders

Sitecore Data Providers

Sitecore uses Data providers to resolve item and field values, each database in Sitecore is composed of one to many data providers. Custom data providers can be added to existing databases such as master, web and core. You can also introduce your own database and data providers. A custom data provider can be used to add items to the tree or it can even be used to provide values to specific fields. Data coming from a provider is indistinguishable from data being provided from a default provider to the content author.

<database id="master" singleInstance="true"     type="Sitecore.Data.Database, Sitecore.Kernel">
        <param desc="name">$(id)</param>
        <icon>Images/database_master.png</icon>
        <dataProviders hint="list:AddDataProvider">
          <dataProvider ref="dataProviders/main" param1="$(id)">
            <prefetch hint="raw:AddPrefetch">
              <sc.include file="/App_Config/Prefetch/Common.config" />
              <sc.include file="/App_Config/Prefetch/Master.config" />
            </prefetch>
          </dataProvider>
        </dataProviders>
      </database>

In this snippet from the Web configuration we can see that the master database is composed of a single data provider, we can add our own provider to the master data base as well and "chain" it to the existing providers. Chaining allows multiple providers to resolve a data access call from the Sitecore API.

Data Provider Use Cases

Below are several examples of how data providers can be leveraged to integrate data.

Provider Only Items

In a Provider Only Item scenario a node in the content tree is identified as the root node. All descendants of this node are resolved by the Data Provider.

Native Sitecore SQL Provider Items With Fields Resolved By A Custom Provider

This approach leverages code that will create item stubs based on meta data provided from the custom provider. Once these items have been created the GetItemFields the provider will implement the GetItemFields method. The GetItemFields method should have a relevant conditional to ensure that it only returns values for the fields resolved by the custom provider.

Hybrid Provider

A Hybrid Provider will allow the coexistence of Sitecore SQL Provider items and items provided by the custom provider to be intermingled. From the content authors perspective the items provided by the custom provider are indistinguishable from native Sitecore items.

Adding A Database and Custom Provider

Another possibility is to add an entirely new database to the provider. This approach allows you to clearly isolate what data is coming from the provider.