Подтвердить что ты не робот

Конфигурация кэша NHibernate L2 в Fluent NHibernate

Возможно ли настроить поставщика кэша L2 в коде через FHN?

Добавление строки в следующую конфигурацию - это то, что мне нужно:

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

Приветствия

AWC

4b9b3361

Ответ 1

Это возможно из FNH, в приведенном ниже примере см. свойство "Cache":

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 кажется, что конфигурация немного отличается. Используйте пакет nuget для SysCache от 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();