Configuration Fluent NHibernate中的NHibernate二级缓存配置

Configuration Fluent NHibernate中的NHibernate二级缓存配置,configuration,caching,fluent-nhibernate,velocity,Configuration,Caching,Fluent Nhibernate,Velocity,ti是否可以通过FHN在代码中配置二级缓存提供程序 在以下配置中添加一行是我的目标: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromConnectionStringWithKey("Temp")).ShowSql()) .Mappings(m => m.FluentMappin

ti是否可以通过FHN在代码中配置二级缓存提供程序

在以下配置中添加一行是我的目标:

 return Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromConnectionStringWithKey("Temp")).ShowSql())
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<IMap>())
                .ExposeConfiguration(c => { })
                .BuildSessionFactory();
流畅地返回。Configure()
.Database(MsSqlConfiguration.MsSql2005.ConnectionString(c=>c.fromConnectionString WithKey(“Temp”)).ShowSql()
.Mappings(m=>m.FluentMappings.AddFromAssemblyOf())
.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();
流畅返回。配置(文件配置)
.数据库(MSSQL)配置
MsSql2005
.ConnectionString(c=>c.FromConnectionStringWithKey(“Temp”))
.ShowSql()
.Cache(c=>c.ProviderClass(typeof(NHibernate.Cache.HashtableCacheProvider).AssemblyQualifiedName)
.UseQueryCache()))
.Mappings(m=>m.FluentMappings.AddFromAssemblyOf())
.ExposeConfiguration(c=>{
c、 EventListeners.PostLoadEventListeners=new IPostLoadEventListener[]{new TestPostLoadListener()};
})
.BuildSessionFactory();
干杯

AWC


注意,对于Fluent NHibernate>=3.4.0.0,配置似乎略有不同。从中为SysCache使用nuget包

流畅返回。配置(文件配置)
.数据库(MSSQL)配置
MsSql2005
.ConnectionString(c=>c.FromConnectionStringWithKey(“Temp”))
.ShowSql())
.Cache(c=>c.ProviderClass().UseQueryCache())
.Mappings(m=>m.FluentMappings.AddFromAssemblyOf())
.ExposeConfiguration(c=>{
c、 EventListeners.PostLoadEventListeners=new IPostLoadEventListener[]{new TestPostLoadListener()};
})
.BuildSessionFactory();

这可以通过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();
流畅返回。配置(文件配置)
.数据库(MSSQL)配置
MsSql2005
.ConnectionString(c=>c.FromConnectionStringWithKey(“Temp”))
.ShowSql()
.Cache(c=>c.ProviderClass(typeof(NHibernate.Cache.HashtableCacheProvider).AssemblyQualifiedName)
.UseQueryCache()))
.Mappings(m=>m.FluentMappings.AddFromAssemblyOf())
.ExposeConfiguration(c=>{
c、 EventListeners.PostLoadEventListeners=new IPostLoadEventListener[]{new TestPostLoadListener()};
})
.BuildSessionFactory();
干杯

AWC


注意,对于Fluent NHibernate>=3.4.0.0,配置似乎略有不同。从中为SysCache使用nuget包

流畅返回。配置(文件配置)
.数据库(MSSQL)配置
MsSql2005
.ConnectionString(c=>c.FromConnectionStringWithKey(“Temp”))
.ShowSql())
.Cache(c=>c.ProviderClass().UseQueryCache())
.Mappings(m=>m.FluentMappings.AddFromAssemblyOf())
.ExposeConfiguration(c=>{
c、 EventListeners.PostLoadEventListeners=new IPostLoadEventListener[]{new TestPostLoadListener()};
})
.BuildSessionFactory();

ProviderClass方法接受类型参数,用法可以重写为
c.ProviderClass()
:)请注意,您可能已经知道:不要对生产代码使用哈希表缓存提供程序。为什么不使用?其他可用选项有哪些?ProviderClass方法接受类型参数,用法可以重写为
c。ProviderClass()
:)请注意,您可能已经知道:不要对生产代码使用哈希表缓存提供程序。为什么不使用?还有什么其他选择?