views:

632

answers:

1

Is ti possible to configure the L2 cache provider in code via FHN?

Adding a line to the following config is what I'm after:

 return Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromConnectionStringWithKey("Temp")).ShowSql())
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<IMap>())
                .ExposeConfiguration(c => { })
                .BuildSessionFactory();

Cheers

AWC

+11  A: 

This is possible from FNH, in the example below see the 'Cache' property:

 return Fluently.Configure(fileConfiguration)
                .Database(MsSqlConfiguration
                          .MsSql2005
                          .ConnectionString(c => c.FromConnectionStringWithKey("Temp"))
                          .ShowSql()
                          .Cache(c => c.ProviderClass(typeof(NHibernate.Cache.HashtableCacheProvider).AssemblyQualifiedName)
                                       .UseQueryCache()))
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<IMap>())
                .ExposeConfiguration(c =>
                                         {
                                             c.EventListeners.PostLoadEventListeners = new IPostLoadEventListener[] {new TestPostLoadListener()};
                                         })
                .BuildSessionFactory();

Cheers

AWC

AWC
ProviderClass method accepts type parameter and usage can be rewritten as `c.ProviderClass<HashTableCacheProvider>()`. :)
Arnis L.
Just a note you probably already know: do not use the HashTable Cacheprovider for production code.
Hace