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


C# Configuration.SessionFactoryName方法代码示例

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


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

示例1: ConfigureNHibernate

		/// <summary>
		/// Configure NHibernate
		/// </summary>
		private static Configuration ConfigureNHibernate()
		{
			Configuration configure = new Configuration();
			configure.SessionFactoryName("SessionFactory");

			configure.DataBaseIntegration(db =>
				{
					db.Dialect<MsSql2008Dialect>();
					db.Driver<SqlClientDriver>();
					db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
					db.IsolationLevel = IsolationLevel.ReadCommitted;

					db.ConnectionStringName = RegtestingServerConfiguration.DefaultConnectionString;
					//db.Timeout = 10;

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

			HbmMapping hbmMapping = GetMappings();
			configure.AddDeserializedMapping(hbmMapping,"NHMapping");
			SchemaMetadataUpdater.QuoteTableAndColumns(configure);

			return configure;
		}
开发者ID:florianwittmann,项目名称:regtesting,代码行数:30,代码来源:ApplicationContext.cs

示例2: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Started publisher and inserting data.");
            Publisher.Start();
    
            var config = new Configuration();
            config.Configure("nh.sqlserver.config");
            config.SessionFactoryName("Test session factory");
            config.AddAssembly(typeof(Dog).Assembly);

            new SchemaUpdate(config).Execute(false, true);
            
            using(var sessionFactory = config.BuildSessionFactory())
            {
                Stopwatch sw = new Stopwatch();

                sw.Start();
                InsertData(sessionFactory);
                Console.WriteLine("Inserting data  with logging took: {0}", sw.Elapsed);

                sw.Restart();
                Publisher.Shutdown();
                Console.WriteLine("Publisher shutdown complete in {0}", sw.Elapsed);

                Console.WriteLine("inserting data with publisher shutdown");
                sw.Restart();
                InsertData(sessionFactory);
                Console.WriteLine("Inserting data  without logging took: {0}", sw.Elapsed);
            }
            Console.ReadLine();
        }
开发者ID:seif,项目名称:NHibernate.ZMQLogPublisher,代码行数:31,代码来源:Program.cs

示例3: ConfigureNHibernate

        static Configuration ConfigureNHibernate()
        {
            var configure = new Configuration();
            configure.SessionFactoryName("HemArkivAccess");

            configure.DataBaseIntegration(db =>
            {
                db.Dialect<NHibernate.JetDriver.JetDialect>();
                db.Driver<NHibernate.JetDriver.JetDriver>();
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;

                db.ConnectionStringName = "HemArkivAccess";
                db.Timeout = 10;

                // enabled for testing
                db.LogFormattedSql = true;
                db.LogSqlInConsole = false;
                db.AutoCommentSql = false;
                db.Timeout = 10;
                //db.ConnectionProvider<NHibernate.Connection.DriverConnectionProvider>();
            });

            var mapping = GetMappings();
            configure.AddDeserializedMapping(mapping, "HemArkivAccess");

            return configure;
        }
开发者ID:marcusholmgren,项目名称:NHemarkiv,代码行数:27,代码来源:ConfigurationBuilder.cs

示例4: BuildConfiguration

        public Configuration BuildConfiguration(string connectionString, string sessionFactoryName)
        {
            Contract.Requires(!string.IsNullOrEmpty(connectionString), "ConnectionString is null or empty");
            Contract.Requires(!string.IsNullOrEmpty(sessionFactoryName), "SessionFactory name is null or empty");
            Contract.Requires(!string.IsNullOrEmpty(_databaseSchema), "Database Schema is null or empty");
            Contract.Requires(_configurator != null, "Configurator is null");

            return CatchExceptionHelper.TryCatchFunction(
                () =>
                {
                    DomainTypes = GetTypeOfEntities(_assemblies);

                    if (DomainTypes == null)
                        throw new Exception("Type of domains is null");

                    var configure = new Configuration();
                    configure.SessionFactoryName(sessionFactoryName);

                    configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
                    configure.DataBaseIntegration(db => GetDatabaseIntegration(db, connectionString));

                    if (_configurator.GetAppSettingString("IsCreateNewDatabase").ConvertToBoolean())
                    {
                        configure.SetProperty("hbm2ddl.auto", "create-drop");
                    }

                    configure.Properties.Add("default_schema", _databaseSchema);
                    configure.AddDeserializedMapping(GetMapping(),
                                                     _configurator.GetAppSettingString("DocumentFileName"));

                    SchemaMetadataUpdater.QuoteTableAndColumns(configure);

                    return configure;
                }, Logger);
        }
开发者ID:ghy,项目名称:ConfORMSample,代码行数:35,代码来源:ConfORMConfigBuilder.cs

示例5: 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

示例6: ConfigureNHibernate

 public static Configuration ConfigureNHibernate()
 {
     var configure = new Configuration();
     configure.SessionFactoryName("Demo");
     configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());
     configure.DataBaseIntegration(db =>
     {
         db.Dialect<MsSql2008Dialect>();
         db.Driver<SqlClientDriver>();
         db.ConnectionString = ConnectionString;
         db.LogSqlInConsole = true;//用于显示输出SQL
     });
     return configure;
 }
开发者ID:wgang10,项目名称:ZYWeb,代码行数:14,代码来源:NhConfig.cs

示例7: GetConfiguration

        public static Configuration GetConfiguration()
        {
            var configure = new Configuration();
            configure.SessionFactoryName("NHibernateDB");

            //Proxy扩展方法用于配置NHibernate延迟加载的字节码提供程序
            configure.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>());

            configure.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2005Dialect>();
                db.Driver<SqlClientDriver>();
                db.ConnectionString = _ConnectionString;
            });

            return configure;
        }
开发者ID:wgang10,项目名称:ZYWeb,代码行数:17,代码来源:DBHelper.cs

示例8: BuildConfiguration

        private static Configuration BuildConfiguration()
        {
            Configuration cfg = new Configuration();
            cfg.SessionFactoryName("Sample.ReadModel");

            cfg.DataBaseIntegration(db =>
            {
                db.Dialect<NHibernate.Dialect.MsSql2008Dialect>();
                db.Driver<NHibernate.Driver.SqlClientDriver>();
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                db.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ReadModel"].ConnectionString;
                db.AutoCommentSql = true;
                db.LogSqlInConsole = false;
                db.LogFormatedSql = true;
                db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'";
            });

            cfg.AddAssembly(typeof(NHibernateMappings).Assembly);

            return cfg;
        }
开发者ID:james-wu,项目名称:CQRSEventSourcingSample,代码行数:21,代码来源:NHibernateStorageConfigModule.cs

示例9: ConfigureNHibernate

 public Configuration ConfigureNHibernate()
 {
     var configure = new Configuration();
     configure.SessionFactoryName("Demo");
     configure.Proxy(p =>
     {
         p.Validation = false;
         p.ProxyFactoryFactory<ProxyFactoryFactory>();
     });
     configure.DataBaseIntegration(db =>
     {
         db.Dialect<MsSql2008Dialect>();
         db.Driver<SqlClientDriver>();
         db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
         db.IsolationLevel = IsolationLevel.ReadCommitted;
         db.ConnectionString = ConnectionString;
         db.Timeout = 10;
         db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'";
     });
     return configure;
 }
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:21,代码来源:NHIntegrationTest.cs

示例10: BuildConfiguration

        public static Configuration BuildConfiguration(string connectionString)
        {
            var configure = new Configuration();

            configure.SessionFactoryName("SessionFactoryName");

            configure.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2008Dialect>();
                db.Driver<SqlClientDriver>();
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                db.IsolationLevel = IsolationLevel.ReadCommitted;
                db.ConnectionString = connectionString;
                db.Timeout = 10;

                db.LogFormattedSql = true;
                db.LogSqlInConsole = true;
                db.AutoCommentSql = true;
            });
            InitMappings(configure);
            GenerateSchema(configure);
            return configure;
        }
开发者ID:drypa,项目名称:BlogSample_v2,代码行数:23,代码来源:NHibernateConfigurator.cs

示例11: ConfigureNhibernate

        public static NHibernate.Cfg.Configuration ConfigureNhibernate()
        {
            var configure = new  NHibernate.Cfg.Configuration();
            configure.SessionFactoryName("BuildIt");

            configure.DataBaseIntegration(db =>
            {
                //*** SQL 2012 Express
                db.Dialect<MsSql2012Dialect>();
                db.Driver<SqlClientDriver>();

                db.ConnectionString = "Data Source=.\\sqlexpress2012;Initial Catalog=Dig;Integrated Security=True;Application Name=DigDb;";
                //db.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["digdb"].ConnectionString;

                db.Timeout = 10;

                //*** Testing Settings
                db.LogFormattedSql = true;
                db.LogSqlInConsole = true;
                db.AutoCommentSql = true;
            });
            return configure;
        }
开发者ID:deftoneYo,项目名称:dig,代码行数:23,代码来源:NhibernateHelper.cs

示例12: NHibernateConfigurationInBuild

        public static void NHibernateConfigurationInBuild(TestContext context)
        {
            log4net.Config.XmlConfigurator.Configure();

            Configuration cfg = new Configuration();

            cfg.SessionFactoryName("BuildIt");

            cfg.DataBaseIntegration(db =>
            {
                db.LogSqlInConsole = true;
                db.ConnectionString = @"Server=localhost;initial catalog=nhibernate;User Id=sa;Password=masterkey;";
                db.Driver<SqlClientDriver>();
                db.Dialect<MsSql2012Dialect>();
            });

            var mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            cfg.AddAssembly(Assembly.GetExecutingAssembly());

            SessionFactory = cfg.BuildSessionFactory();
        }
开发者ID:hrickmachado,项目名称:Crowdlearning-Tecnologia-NHibernate,代码行数:24,代码来源:Context.cs

示例13: initConfiguration

        private Configuration initConfiguration()
        {
            var configure = new Configuration();
            configure.SessionFactoryName("BuildIt");

            configure.DataBaseIntegration(db =>
            {
                db.ConnectionProvider<DriverConnectionProvider>();
                db.Dialect<MsSql2008Dialect>();
                db.Driver<Sql2008ClientDriver>();
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                db.IsolationLevel = IsolationLevel.ReadCommitted;
                db.ConnectionString = ConnectionString;
                db.Timeout = 10;
                db.BatchSize = 20;

                if (ShowLogs)
                {
                    db.LogFormattedSql = true;
                    db.LogSqlInConsole = true;
                    db.AutoCommentSql = false;
                }
            });

            configure.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver,
                typeof(ProfiledSql2008ClientDriver).AssemblyQualifiedName);

            return configure;
        }
开发者ID:yao-yi,项目名称:DNTProfiler,代码行数:29,代码来源:NHConfig.cs

示例14: InitializeNHibernate

        //        public class Order
        //        {
        //            public int Id { get; set; }
        //            public Customer Customer { get; set; }
        //        }
        static void InitializeNHibernate()
        {
            NHibernateProfiler.Initialize();

            cfg = new Configuration();
            cfg.DataBaseIntegration(x =>
                                        {
                                            x.ConnectionStringName = "adventureworks";
                                            x.Driver<SqlClientDriver>();
                                            x.Dialect<MsSql2008Dialect>();
                                            x.IsolationLevel = IsolationLevel.ReadCommitted;
                                            x.Timeout = 10;
                                        });
            cfg.SessionFactoryName("AdventureWorks");
            cfg.Cache(x =>
                          {
                              x.Provider<HashtableCacheProvider>();
                              x.UseQueryCache = true;
                          });
            cfg.SessionFactory().GenerateStatistics();
            cfg.AddAssembly(typeof (Customer).Assembly);
        }
开发者ID:JamesKovacs,项目名称:NHibernateCourseMaterials,代码行数:27,代码来源:Program.cs

示例15: ConfigureNHibernate

        /// <summary>
        /// Configuration nhibernate and data base
        /// </summary>
        /// <returns></returns>
        private Configuration ConfigureNHibernate()
        {
            var configure = new Configuration();
            configure.SessionFactoryName("SQL");

            configure.DataBaseIntegration(db =>
            {
                db.Dialect<MsSql2012Dialect>();
                db.Driver<NHibernate.Driver.SqlClientDriver>();
                db.ConnectionString = this.ConnectionString.ConnectionString;
                db.Timeout = 10;
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                db.IsolationLevel = System.Data.IsolationLevel.ReadCommitted;

            });

            return configure;
        }
开发者ID:Junior112,项目名称:GenericMapper,代码行数:22,代码来源:ConfigurationFactory.cs


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