當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。