Back to Devexpress

DataCacheConfiguration Class

corelibraries-devexpress-dot-xpo-dot-db-dot-helpers-8ec151dc.md

latest3.8 KB
Original Source

DataCacheConfiguration Class

Contains configuration settings for cached data stores.

Namespace : DevExpress.Xpo.DB.Helpers

Assembly : DevExpress.Data.v25.2.dll

NuGet Package : DevExpress.Data

Declaration

csharp
public class DataCacheConfiguration
vb
Public Class DataCacheConfiguration

The following members return DataCacheConfiguration objects:

Remarks

A DataCacheConfiguration object instance is used to configure a cached data store using a Root element’s DataCacheRoot.Configure method. For the MSSql2005SqlDependencyCacheRoot, call the corresponding MSSql2005SqlDependencyCacheRoot.CreateSqlDependencyCacheRoot overloaded method.

csharp
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.Xpo.DB.Helpers;

// ...
string connectionString = MSSqlConnectionProvider.GetConnectionString("localhost", "SampleDB");
MSSqlConnectionProvider provider = (MSSqlConnectionProvider)XpoDefault.GetConnectionProvider(
    connectionString,
    AutoCreateOption.DatabaseAndSchema
);
DataCacheConfiguration cacheConfig = new DataCacheConfiguration(
    DataCacheConfigurationCaching.InList, "Customers", "Departments");

// Configuring DataCacheRoot
DataCacheRoot cacheRoot = new DataCacheRoot(provider);
cacheRoot.Configure(cacheConfig);

// Configuring MSSql2005SqlDependencyCacheRoot
IDisposable[] objectsToDispose;
ICachedDataStore cachedDataStore = 
    (ICachedDataStore)MSSql2005SqlDependencyCacheRoot.CreateSqlDependencyCacheRoot(
    provider,
    cacheConfig,
    out objectsToDispose
);
vb
Imports DevExpress.Xpo
Imports DevExpress.Xpo.DB
Imports DevExpress.Xpo.DB.Helpers

' ...
Private connectionString As String = _
MSSqlConnectionProvider.GetConnectionString("localhost", "SampleDB")
Private provider As MSSqlConnectionProvider = CType( _
XpoDefault.GetConnectionProvider(connectionString, AutoCreateOption.DatabaseAndSchema), _
MSSqlConnectionProvider)
Private cacheConfig As New DataCacheConfiguration(DataCacheConfigurationCaching.InList, _
"Customers", "Departments")

' Configuring DataCacheRoot
Private cacheRoot As New DataCacheRoot(provider)
cacheRoot.Configure(cacheConfig)

' Configuring MSSql2005SqlDependencyCacheRoot
Dim objectsToDispose() As IDisposable
Dim cachedDataStore As ICachedDataStore = CType( _
MSSql2005SqlDependencyCacheRoot.CreateSqlDependencyCacheRoot( _
provider, cacheConfig, objectsToDispose), ICachedDataStore)

Tip

To cache all tables, pass the All enumeration value to the DataCacheConfiguration.Caching property. All tables will be cached in this instance, regardless of their inclusion in the configuration settings. To cache all tables except for the tables specified, use the NotInList value.

Inheritance

Object DataCacheConfiguration

See Also

DataCacheConfiguration Members

DevExpress.Xpo.DB.Helpers Namespace