configuration - Fluent NHibernate 中的 NHibernate L2 缓存配置

标签 configuration caching fluent-nhibernate velocity

是否可以通过 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("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 中的 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();

关于configuration - Fluent NHibernate 中的 NHibernate L2 缓存配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2020730/

相关文章:

fluent-nhibernate - 向 Fluent Nhibernate 自动映射类的属性添加(唯一)索引

linq - NHibernate、NHibernate.Linq 和 FluentNHibernate? throw 错误

configuration - 在 jekyll 中配置每个目录的永久链接设置

testing - 视频路径问题

c# - 在没有 N+1 的情况下通过 NHibernate 进行查询 - 包含示例

Python包代理/缓存

npm - 无法识别 Azure Pipelines 缓存任务和 ng

java - 在配置文件中加密密码?

c# - .net 路由开头的可选参数

caching - 扩展和集群 JPA