Fluent NHibernate 中的 NHibernate L2 缓存配置 [英] NHibernate L2 Cache configuration in Fluent NHibernate
本文介绍了Fluent NHibernate 中的 NHibernate L2 缓存配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过 FHN 在代码中配置 L2 缓存提供程序?
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();
干杯
AWC
推荐答案
这可以从 FNH 中实现,在下面的示例中,请参阅缓存"属性:
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();
干杯
AWC
注意,对于 Fluent NHibernate >= 3.4.0.0,它的配置似乎略有不同.使用来自 http://nuget.org/packages/NHibernate.Caches.SysCache<的 nuget 包进行 SysCache/a>
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();
这篇关于Fluent NHibernate 中的 NHibernate L2 缓存配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文