开发者

Configuration SysCache2 With Fluent NHibernate

开发者 https://www.devze.com 2022-12-10 01:31 出处:网络
How can i configure SysCache2 2nd-Level Cache wit开发者_StackOverflowh Fluent NHibernate configuration ?

How can i configure SysCache2 2nd-Level Cache wit开发者_StackOverflowh Fluent NHibernate configuration ?

    private ISessionFactory CreateSessionFactory()
    {
        return Fluently.Configure()
            .Database(MsSqlConfiguration.MsSql2008.ConnectionString(_connectionString)
            .Cache(c => c.UseQueryCache())
            .Dialect<FullTextSearchEnabledMsSql2008Dialect>()
            .UseReflectionOptimizer())
            .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
            .BuildSessionFactory();
    }


I didn't have any trouble with it.

public static ISessionFactory Create(string connectionString) {
            // fluently configure an ms-sql 2008 database
            return FluentNHibernate.Cfg.Fluently.Configure()
            .Database(FluentNHibernate.Cfg.Db.MsSqlConfiguration.MsSql2008
                      .ConnectionString(c => c.Is(connectionString))
                      .AdoNetBatchSize(50)
                      .FormatSql()
                      .UseReflectionOptimizer())
            .Cache(c => c
                   .ProviderClass<NHibernate.Caches.SysCache2.SysCacheProvider>()
                   .UseQueryCache()
                   .UseSecondLevelCache()
                   .UseMinimalPuts())
            .ExposeConfiguration(config => {
                new NHibernate.Tool.hbm2ddl.SchemaExport(config)
                .Drop(/* Output to console */ false, /* Execute script against database */ true);
            })
            .ExposeConfiguration(config => {
                new NHibernate.Tool.hbm2ddl.SchemaExport(config)
                .Create(/* Output to console */ true, /* Execute script against database */ true);
            })
            .Mappings(m => {
                    m.FluentMappings.Conventions.Setup(x => {
                            x.AddFromAssemblyOf<Mappings.AspectMap>();
                            x.Add(FluentNHibernate.Conventions.Helpers.AutoImport.Never());
                        });
                m.FluentMappings.AddFromAssembly(System.Reflection.Assembly.GetExecutingAssembly());
            })
            .BuildSessionFactory();
        }


I don't think you can. You have to configure it through web.config.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号