Fluent NHibernate 中的 NHibernate L2 缓存配置

发布于 2024-08-17 02:26:19 字数 446 浏览 5 评论 0原文

是否可以通过 FHN 在代码中配置 L2 缓存提供程序?

我想要在以下配置中添加一行:

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

Cheers

AWC

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

熟人话多 2024-08-24 02:26:19

这可以从 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();

Cheers

AWC


注意,对于 Fluent NHibernate >= 3.4.0.0,配置似乎略有不同。使用 http://nuget.org/packages/NHibernate.Caches.SysCache< 中的 SysCache 的 nuget 包/a>

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();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文