SQL server CE for Caching Application block

Topics: Caching Application Block
Oct 30, 2008 at 8:18 PM
Can someone help me get started with using SQL server CE for caching application block? If you have an example configuration file that would be great. The CreateCachingDatabase.sql file contains stored procedures but SQL server CE doesn't support that. What tables do I need to get setup in order to use a SQL server CE file for caching?

Thanks!
Oct 30, 2008 at 10:26 PM

            Database db = DatabaseFactory.CreateDatabase("CEConn");

Resolves properly to db = {Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.SqlCeDatabase} but when I use the Unity framework to build an object that constructs an object that  uses 

[InjectionConstructor]
        public Storage([Dependency("Cache Manager")]ICacheManager cacheManager)

I get the following error 

Resolution of the dependency failed, type = "EnterpriseLibraryTest.Storage", name = "". Exception message is: The current build operation (build key Build Key[EnterpriseLibraryTest.Storage, null]) failed: The parameter cacheManager could not be resolved when attempting to call constructor EnterpriseLibraryTest.Storage(Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager cacheManager). (Strategy type BuildPlanStrategy, index 3)

My thought is that there  is a custom mapping for the Data Access Application Block that is why the CreateDatabase worked. However for the Caching Application Block there is no such custom mapping.

Has anyone got SQL server CE to work with the Caching block?


Here is my config

<configuration>
  
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />
    <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching" />
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
  </configSections>
  
  
  <dataConfiguration defaultDatabase="CEConn">
    <providerMappings>
      <add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.SqlCeDatabase, Microsoft.Practices.EnterpriseLibrary.Data.SqlCe"
        name="Microsoft.SqlServerCe.Client" />
    </providerMappings>
  </dataConfiguration>
  
  
  <connectionStrings>
    <add name="CEConn" connectionString="Data Source='C:\ploc\EnterpriseLibraryTest\EnterpriseLibraryTest\test2.sdf'"
      providerName="Microsoft.SqlServerCe.Client" />
  </connectionStrings>
  
  <cachingConfiguration defaultCacheManager="Cache Manager">
    <cacheManagers>
      <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000"
        numberToRemoveWhenScavenging="10" backingStoreName="Data Cache Storage"
        type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching"
        name="Cache Manager" />
    </cacheManagers>
    <backingStores>
      <add databaseInstanceName="CEConn" partitionName=""
        encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database"
        name="Data Cache Storage" />
    </backingStores>
  </cachingConfiguration>
  
  
  <unity>
    <containers>
      <container>
        <extensions>
          <add type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity.EnterpriseLibraryCoreExtension, Microsoft.Practices.EnterpriseLibrary.Common" />
          <add type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.Unity.CachingBlockExtension, Microsoft.Practices.EnterpriseLibrary.Caching" />
        </extensions>
      </container>
    </containers>
  </unity>
</configuration>
Oct 31, 2008 at 3:07 AM
Hi, I haven't tried working on SQL SERVER CE yet but I found this page, see if this helps. http://huntjason.spaces.live.com/blog/cns!9D2E96F2AA6AE85F!440.entry