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


C# SchemaUpdate.Execute方法代码示例

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


在下文中一共展示了SchemaUpdate.Execute方法的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: 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

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

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

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

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