当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.CurrentSessionContext方法代码示例

本文整理汇总了C#中NHibernate.Cfg.Configuration.CurrentSessionContext方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.CurrentSessionContext方法的具体用法?C# Configuration.CurrentSessionContext怎么用?C# Configuration.CurrentSessionContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.Cfg.Configuration的用法示例。


在下文中一共展示了Configuration.CurrentSessionContext方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSessionFactory

        /// <summary>
        /// Creates session factory
        /// </summary>
        /// <param name="configurationReader">configuration reader</param>
        /// <returns></returns>
        private static ISessionFactory CreateSessionFactory(IConfigurationReader configurationReader)
        {
            var configuration = new NHibernate.Cfg.Configuration();
            configuration.SessionFactoryName("Jumblocks Blog");

            configuration.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2008FixedDialect>();
                db.IsolationLevel = IsolationLevel.ReadCommitted;
                db.ConnectionString = configurationReader.ConnectionStrings["BlogDb"].ConnectionString;
                db.BatchSize = 100;

                //for testing
                db.LogFormattedSql = true;
                db.LogSqlInConsole = true;
                db.AutoCommentSql = true;
            });

            var mapper = new ModelMapper();
            mapper.AddMapping<BlogPostMap>();
            mapper.AddMapping<BlogUserMap>();
            mapper.AddMapping<ImageReferenceMap>();
            mapper.AddMapping<TagMap>();
            mapper.AddMapping<SeriesMap>();

            mapper.AddMapping<UserMap>();
            mapper.AddMapping<RoleMap>();
            mapper.AddMapping<OperationMap>();

            configuration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
            configuration.CurrentSessionContext<WebSessionContext>();

            return configuration.BuildSessionFactory();
        }
开发者ID:AndyCC,项目名称:Jumbleblocks-website,代码行数:39,代码来源:DatabaseSetup.cs

示例2: Apply

		public virtual void Apply(Configuration configuration, IDatabaseProvider databaseProvider)
		{
			configuration.CurrentSessionContext<CallSessionContext>();

			configuration.DataBaseIntegration(db => SetDatabase(db, databaseProvider, configuration));

			configuration.Cache(SetCache);

			configuration.Proxy(SetProxy);
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:10,代码来源:DefaultConfiguration.cs

示例3: Initialize

        public static void Initialize()
        {
            if (SessionFactoryHolder.DefaultSessionFactory != null) { return; }

            var cfg = new Configuration();
            cfg.CurrentSessionContext<WcfOperationSessionContext>()
               .DataBaseIntegration(ForSQLiteInMemory)
               .Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
               .SessionFactory()
                    .GenerateStatistics();

            SessionFactoryHolder.DefaultSessionFactory = cfg.BuildSessionFactory();
        }
开发者ID:n0name85,项目名称:BonusBits.CodeSamples,代码行数:13,代码来源:Bootstrapper.cs

示例4: GetNHibernateSessionFactory

 public static ISessionFactory GetNHibernateSessionFactory()
 {
     var configure = new NHibernate.Cfg.Configuration();
     configure.DataBaseIntegration(delegate(NHibernate.Cfg.Loquacious.IDbIntegrationConfigurationProperties dbi) {
         dbi.ConnectionStringName = "mvcWithNHibernate";
         dbi.Dialect<NHibernate.Dialect.MySQLDialect>();
         dbi.Driver<NHibernate.Driver.MySqlDataDriver>();
         dbi.Timeout = 255;
     });
     configure.CurrentSessionContext<NHibernate.Context.WebSessionContext>();
     //configure.AddAssembly(typeof(NHibernateMappings.User).Assembly);
     configure.AddAssembly(typeof(NHibernateMappings.Shop).Assembly);
     return configure.BuildSessionFactory();
 }
开发者ID:07033320a,项目名称:VictoryMana-NHibernate,代码行数:14,代码来源:NHibernateHelper.cs

示例5: CreateSessionFactory

        private void CreateSessionFactory(string assemblyName, string connStr)
        {
            Configuration cfg = new Configuration();
            cfg.CurrentSessionContext<ThreadStaticSessionContext>();
            cfg.DataBaseIntegration(o =>
                {
                    o.ConnectionProvider<DriverConnectionProvider>();
                    o.Dialect<SQLiteDialect>();
                    o.Driver<SQLite20Driver>();
                    o.ConnectionString = connStr;
                    o.BatchSize = 100;
                });
            cfg.AddAssembly(assemblyName);

            SessionFactory = cfg.BuildSessionFactory();

            SchemaExport = new SchemaExport(cfg);
            SchemaExport.Create(false, true);
        }
开发者ID:wfsiew,项目名称:ASP.NET_MVC3,代码行数:19,代码来源:NHibernateFixtureBase.cs

示例6: Start

        /// <summary>
        /// Starts this instance.
        /// </summary>
        public static void Start()
        {
            var configuration = new Configuration();
            configuration.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2012Dialect>();
                db.Driver<SqlClientDriver>();
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                db.IsolationLevel = IsolationLevel.ReadCommitted;
                db.SchemaAction = SchemaAutoAction.Validate;
                db.ConnectionStringName = ConnectionStringName;
            });

            configuration.CurrentSessionContext<WebSessionContext>();
            var factory = Fluently.Configure(configuration)
                .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(TodoMap).Assembly))
                .ExposeConfiguration(cfg => new SchemaExport(cfg).Execute(false, true, false))
                .BuildSessionFactory();

            SessionSource.SetFactory(factory);
        }
开发者ID:sunpa,项目名称:SampleTodo,代码行数:24,代码来源:NHibernateConfig.cs

示例7: GetNHibernateSessionFactory

        public static ISessionFactory GetNHibernateSessionFactory(string connStringKeyName)
        {
            if (string.IsNullOrEmpty(connStringKeyName))
                throw new ArgumentNullException("connStringKeyName");

            var configs = new NHibernate.Cfg.Configuration();

            configs.DataBaseIntegration(i =>
            {
                i.Dialect<NHibernate.Dialect.MsSql2012Dialect>();
                i.Driver<NHibernate.Driver.Sql2008ClientDriver>();
                i.ConnectionStringName = connStringKeyName;
                i.ConnectionProvider<NHibernate.Connection.DriverConnectionProvider>();
            });

            configs.CurrentSessionContext<NHibernate.Context.WebSessionContext>();

            // assembly of poco classes
            configs.AddAssembly(typeof(NHibernateMVCApp.Repository.Mappings.Product).Assembly);

            return configs.BuildSessionFactory();
        }
开发者ID:goncalod,项目名称:csharp,代码行数:22,代码来源:NHibernateSessionCfg.cs

示例8: Initialize

        public static Configuration Initialize()
        {
            ModelMapper mapper = new ModelMapper();

            mapper.AddMappings(Assembly.GetAssembly(typeof(NHibernateSessionManager)).GetExportedTypes());

            Configuration cfg = new Configuration();

            cfg.DataBaseIntegration(c =>
            {
                c.Driver<SqlServerCeDriver>();
                c.Dialect<MsSqlCe40Dialect>();

                c.LogSqlInConsole = true;
                c.LogFormattedSql = true;

                c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                c.ConnectionString   = ConnectionString;
            });
            cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
            cfg.CurrentSessionContext<ThreadStaticSessionContext>();

            // Set up second level caching
            cfg.Cache(props =>
            {
                props.Provider<AppFabricProvider>();
                props.UseQueryCache = true;
            });

            // (Re-)create the database.
            new SchemaExport(cfg).Execute(false, true, false);

            _sessionFactory = cfg.BuildSessionFactory();

            return cfg;
        }
开发者ID:rageshkrishna,项目名称:NHibernate.Caches.AppFabric,代码行数:36,代码来源:NHibernateSessionManager.cs

示例9: Configure

 public static void Configure()
 {
     NHConguration = new Configuration().Configure();
     NHConguration.CurrentSessionContext<WcfOperationSessionContext>();
     NHConguration.LinqToHqlGeneratorsRegistry<NHibernateLinqToHqlGeneratorsRegistry>();
     sessionFactory = NHConguration.BuildSessionFactory();
 }
开发者ID:dalinhuang,项目名称:cndreams,代码行数:7,代码来源:NHibernateHelper.cs

示例10: ExposeConfiguration

 protected override void ExposeConfiguration(Configuration cfg)
 {
     base.ExposeConfiguration(cfg);
     cfg.CurrentSessionContext<NHibernate.Context.WebSessionContext>();
 }
开发者ID:bea-project,项目名称:bea-web,代码行数:5,代码来源:MySQLWebSessionFactoryFactory.cs


注:本文中的NHibernate.Cfg.Configuration.CurrentSessionContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。