當前位置: 首頁>>代碼示例>>C#>>正文


C# hbm2ddl.SchemaUpdate類代碼示例

本文整理匯總了C#中NHibernate.Tool.hbm2ddl.SchemaUpdate的典型用法代碼示例。如果您正苦於以下問題:C# SchemaUpdate類的具體用法?C# SchemaUpdate怎麽用?C# SchemaUpdate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SchemaUpdate類屬於NHibernate.Tool.hbm2ddl命名空間,在下文中一共展示了SchemaUpdate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Initialize

        public static void Initialize(TestContext context)
        {
            var cfg = new Configuration();
            cfg.DataBaseIntegration(x => {
                x.ConnectionString = "Server=localhost;Database=test;Uid=root;Pwd=kmn23po;";
                x.Driver<MySqlDataDriver>();
                x.Dialect<MySQLDialect>();
                x.LogSqlInConsole = true;
                x.BatchSize = 30;
            });

            var mapper = new ModelMapper();
            mapper.AddMapping<ParentMap>();
            mapper.AddMapping<ParentWithGuidMap>();
            mapper.AddMapping<ChildMap>();

            cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            sessionFactory = cfg.BuildSessionFactory();

            var schemaUpdate = new SchemaUpdate(cfg);
            schemaUpdate.Execute(false, true);

            InsertData();
        }
開發者ID:jplindgren,項目名稱:NHibernateCodeCheat,代碼行數:25,代碼來源:UnitTest1.cs

示例2: TryAlterDbSchema

 public void TryAlterDbSchema()
 {
     var config = ServiceLocator.Current.GetInstance<NHibernate.Cfg.Configuration>();            
     
     var schemaUpdate = new SchemaUpdate(config);            
     schemaUpdate.Execute(true, true);
 }        
開發者ID:marufbd,項目名稱:Zephyr.NET,代碼行數:7,代碼來源:DbTests.cs

示例3: Init

        protected override void Init()
        {
            var config = ConfigureNHibernate();

            var schemaExport = new SchemaUpdate(config);
            schemaExport.Execute(false, true);

            //var schemaCreator = new SchemaExport(config);
            //schemaCreator.Drop(false, true);
            //schemaCreator.Create(false, true);

            Kernel.Register(
                Component.For<ISessionFactory>().LifeStyle.Singleton
                    .UsingFactoryMethod(config.BuildSessionFactory));

            Kernel.Register(Component.For<ISession>().Named("PerThreadSession")
                                 .LifeStyle
                                 .PerThread
                                 .UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession())
                                 .OnCreate((kernel, session) => { session.FlushMode = FlushMode.Commit; }));

            Kernel.Register(Component.For<ISession>().Named("PerWebRequestSession")
                                .LifeStyle
                                .PerWebRequest
                                .UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession())
                                .OnCreate((kernel, session) => { session.FlushMode = FlushMode.Commit; }));
        }
開發者ID:daparadoks,項目名稱:ParadoxProperty,代碼行數:27,代碼來源:PersistenceFacility+.cs

示例4: BaseTest

 public BaseTest()
 {
     _configuration = SessionFactory.GetConfiguration();
     SchemaUpdate su = new SchemaUpdate(_configuration);
     //se.Execute(false, false, true);
     su.Execute(true, true);
 }
開發者ID:qgate,項目名稱:CMS,代碼行數:7,代碼來源:BaseTest.cs

示例5: UpdateExistingDatabase

        public void UpdateExistingDatabase(SchemaDefinition definition)
        {
            CheckDefinitionIsValid(definition);

            var schemaUpdate = new SchemaUpdate(definition.Configuration);
            if (definition.FileDefinition != null && !string.IsNullOrWhiteSpace(definition.FileDefinition.FileName))
            {
                //output the sql to create the db to a file.
                string filename = Path.Combine(string.IsNullOrWhiteSpace(definition.FileDefinition.OutputFolder) ? "" : definition.FileDefinition.OutputFolder, definition.FileDefinition.FileName);

                Action<string> updateExport = x =>
                {
                    using (var file = new FileStream(filename, FileMode.Append, FileAccess.Write))
                    using (var sw = new StreamWriter(file))
                    {
                        sw.Write(x);
                        sw.Close();
                    }
                };

                schemaUpdate.Execute(updateExport, true);
            }
            else
            {
                schemaUpdate.Execute(false, true);
            }
        }
開發者ID:twistedtwig,項目名稱:HoHUtilities,代碼行數:27,代碼來源:SchemaManagementController.cs

示例6: Main

        static void Main(string[] args)
        {
            //var assemblyNames = ConfigurationManager.AppSettings["nhibernate.assemblies"];

            //if (assemblyNames.IsNullOrEmpty())
            //    throw new ConfigurationErrorsException("value required for nhibernate.assemblies, comma seperated list of assemblies");

            //var config = new NHibernate.Cfg.Configuration();
            //config.Configure();

            //foreach (MappingAssembly assembly in TitanConfiguration.Instance.MappingAssemblies)
            //    config.AddAssembly(assembly.Name);

            TitanFramework.Data.NHib.NHibernateHelper.InitialIze();

            var config = TitanFramework.Data.NHib.NHibernateHelper.Configuration;

            var rebuildDatabase = ConfigurationManager.AppSettings["nhibernate.rebuilddatabase"];
            if (TitanFramework.Extensions.StringExtensions.IsNullOrEmpty(rebuildDatabase))
                throw new ConfigurationErrorsException("value required for nhibernate.assemblies, comma seperated list of assemblies");

            switch (rebuildDatabase.ToLower())
            {
                case "rebuild":
                    var schemaExport = new SchemaExport(config);
                    schemaExport.Drop(false, true);
                    schemaExport.Execute(true, false, false);
                    break;
                case "update":
                    var schemaUpdate = new SchemaUpdate(config);
                    schemaUpdate.Execute(true, true);
                    break;
            }
        }
開發者ID:jd-pantheon,項目名稱:Titan-Framework-v2,代碼行數:34,代碼來源:Program.cs

示例7: CreateSchema

        private static void CreateSchema(Configuration cfg)
        {
            var schemaExport = new SchemaUpdate(cfg);

            schemaExport.Execute(true, true);

        }
開發者ID:276398084,項目名稱:KW.OrderManagerSystem,代碼行數:7,代碼來源:NHibernateHelper.cs

示例8: OnFixtureSetup

        protected override void OnFixtureSetup()
        {
            Configuration configuration = Fluently.Configure()
                .Database(SQLiteConfiguration.Standard
                              .ConnectionString(connstr =>
                                                connstr.Is("Data Source=:memory:;Version=3;New=True;"))
                              .Dialect<SQLiteDialect>()
                              .Driver<SQLite20Driver>()
                              .Provider<TestConnectionProvider>()
                              .ShowSql())
                .CurrentSessionContext("thread_static")
                .ProxyFactoryFactory<ProxyFactoryFactory>()
                .Mappings(m =>
                          m.AutoMappings
                              .Add(
                                  AutoMap.Assembly(
                                      Assembly.Load("Blog.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"))
                                      .Where(c => c.BaseType == typeof (Entity) || c.BaseType == typeof (StampedEntity))
                                      .Conventions
                                      .Add<CustomCollectionConvetion>()
                                      .Conventions
                                      .Add<CascadeAll>()
                                      .Conventions.Add<HiLoIndetityStrategy>()
                                      .Conventions.Add<TableNamePluralizeConvention>()
                                      .Conventions.Add<CustomForeignKeyConvention>()))
                                      
                .ExposeConfiguration(ConfigValidator)
                .BuildConfiguration();

            var schema = new SchemaUpdate(configuration);
            schema.Execute(true, true);

            SessionFactory = configuration.BuildSessionFactory();
        }
開發者ID:kibiluzbad,項目名稱:Xango.Blog,代碼行數:34,代碼來源:NhIbernateBaseFixture.cs

示例9: Main

        static void Main(string[] args)
        {
            List<SongInfo> songProperties =  FileReader.GetProperties("music.txt");

            FluentConfiguration config = Fluently
                 .Configure()
                 .Database(MsSqlConfiguration
                               .MsSql2008
                               .ConnectionString(@"Data Source=.\SQLEXPRESS;Initial Catalog=Songs;Integrated Security=True;Pooling=False"))
                               .Mappings(configuration => configuration
                               .FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
                              ;

            var export = new SchemaUpdate(config.BuildConfiguration());
            export.Execute(true, true);

            ISessionFactory sessionFactory = config.BuildSessionFactory();

            using (ISession session = sessionFactory.OpenSession())
            {
                var tracks = session.QueryOver<ArtistInfo>().List();

                foreach (var track in tracks)
                {
                    Console.WriteLine(track);
                    Console.WriteLine("=====");

                }

            }
        }
開發者ID:nightmare40000,項目名稱:MusicDB,代碼行數:31,代碼來源:Program.cs

示例10: BuildSchema

 private static void BuildSchema(Configuration config)
 {
     // This NHibernate tool takes a configuration (with mapping info in)
     // and exports a database schema from it.
     var dbSchemaExport = new SchemaUpdate(config);
     //dbSchemaExport.Drop(false, true);
     dbSchemaExport.Execute(false, true);
 }
開發者ID:cheokjiade,項目名稱:twocube---CZ2006-Software-Engineering,代碼行數:8,代碼來源:InitFactory.cs

示例11: UpdateSchema

 public static void UpdateSchema(string ConnString)
 {
     FNHMVC.Data.Infrastructure.ConnectionHelper.GetConfiguration(ConnString).ExposeConfiguration(cfg =>
     {
         var schemaUpdate = new NHibernate.Tool.hbm2ddl.SchemaUpdate(cfg);
         schemaUpdate.Execute(false, true);
     }).BuildConfiguration();
 }
開發者ID:kostyrin,項目名稱:FNHMVC,代碼行數:8,代碼來源:SchemaTool.cs

示例12: Update_an_existing_database_schema

 public void Update_an_existing_database_schema()
 {
     _cfg = new Configuration();
     _cfg.Configure();
     _cfg.AddAssembly(Assembly.LoadFrom("DataLayer.dll"));
     var update = new SchemaUpdate(_cfg);
     update.Execute(true, false);
 }
開發者ID:tasluk,項目名稱:hibernatingrhinos,代碼行數:8,代碼來源:UpdateSchema_Fixture.cs

示例13: TreatConfiguration

        private static void TreatConfiguration(NHibernate.Cfg.Configuration configuration)
        {
            var update = new SchemaUpdate(configuration);
            update.Execute(false, true);
            //            configuration.SetProperty("current_session_context_class", "web");


        }
開發者ID:Jenny-Ho,項目名稱:ContactManager.MVC,代碼行數:8,代碼來源:NHibernateHelper.cs

示例14: BuildSchema

        /// <summary>
        /// Creates/Updates the database schema.
        /// </summary>        
        private void BuildSchema()
        {
            // Build the schema.
            var schemaUpdate = new SchemaUpdate(_configuration);

            // Create/Update the schema.
            schemaUpdate.Execute(false, true);
        }
開發者ID:MatthewRudolph,項目名稱:Airy,代碼行數:11,代碼來源:SessionFactoryProvider.cs

示例15: SchemaUpdateAddsIndexesThatWerentPresentYet

		public void SchemaUpdateAddsIndexesThatWerentPresentYet()
		{
			Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
			cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1593.TestIndex.hbm.xml", GetType().Assembly);
			var su = new SchemaUpdate(cfg);
			var sb = new StringBuilder(500);
			su.Execute(x => sb.AppendLine(x), false);
			Assert.That(sb.ToString(), Is.StringContaining("create index test_index_name on TestIndex (Name)"));
		}
開發者ID:marchlud,項目名稱:nhibernate-core,代碼行數:9,代碼來源:Fixture.cs


注:本文中的NHibernate.Tool.hbm2ddl.SchemaUpdate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。