NHibernate L2缓存配置在Fluent NHibernate中 [英] NHibernate L2 Cache configuration in Fluent NHibernate
本文介绍了NHibernate L2缓存配置在Fluent NHibernate中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过FHN在代码中配置L2缓存提供程序?
添加一行到以下配置就是我的后续:
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromConnectionStringWithKey(Temp ))。ShowSql())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf< IMap>())
.ExposeConfiguration(c => {})
.BuildSessionFactory );
干杯
AWC
这是可能从FNH,在下面的例子中看到'缓存'属性:
return Fluently.Configure(fileConfiguration)
.Database(MsSqlConfiguration
.MsSql2005
.ConnectionString(c => c.FromConnectionStringWithKey ))
.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();
干杯
AWC
注意,对于Fluent NHibernate> = 3.4.0.0它看起来配置略有不同。从 http://nuget.org/packages/NHibernate.Caches.SysCache使用SysCache的nuget包
return Fluently.Configure(fileConfiguration)
.Database(MsSqlConfiguration
.MsSql2005
.ConnectionString(c => c.FromConnectionStringWithKey(Temp))
.ShowSql())
.Cache(c => c.ProviderClass< SysCacheProvider>()。UseQueryCache ))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf< IMap>())
.ExposeConfiguration(c => {
c.EventListeners.PostLoadEventListeners = new IPostLoadEventListener [] {new TestPostLoadListener()};
})
.BuildSessionFactory();
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
解决方案
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
Note, for Fluent NHibernate >= 3.4.0.0 it appears the configuration is slightly different. Use the nuget package for SysCache from http://nuget.org/packages/NHibernate.Caches.SysCache
return Fluently.Configure(fileConfiguration)
.Database(MsSqlConfiguration
.MsSql2005
.ConnectionString(c => c.FromConnectionStringWithKey("Temp"))
.ShowSql())
.Cache(c => c.ProviderClass<SysCacheProvider>().UseQueryCache())
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<IMap>())
.ExposeConfiguration(c => {
c.EventListeners.PostLoadEventListeners = new IPostLoadEventListener[] {new TestPostLoadListener()};
})
.BuildSessionFactory();
这篇关于NHibernate L2缓存配置在Fluent NHibernate中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文