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


C# SchemaExport.Execute方法代码示例

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


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

示例1: Create

		public string Create()
		{
			var schemaExport = new SchemaExport(configuration);

			databaseProvider.CreateIfNotExists();

			var stringBuilder = new StringBuilder();
			schemaExport.Create(x => stringBuilder.Append(x), false);
			var statement = stringBuilder.ToString();
			statement = string.IsNullOrWhiteSpace(statement) ? null : statement;

			if (!databaseProvider.Exists())
			{
				databaseProvider.Create();
				schemaExport.Execute(false, true, false);
			}
			else
			{
				try
				{
					new SchemaValidator(configuration).Validate();
				}
				catch
				{
					schemaExport.Execute(false, true, false);
				}
			}

			return statement;
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:30,代码来源:NhibernateDatabaseSchema.cs

示例2: CreateSchema

        public void CreateSchema(bool recreate)
        {
            if (_sessionFactory == null)
                _sessionFactory = CreateSessionFactory();

            var schemaExport = new SchemaExport(_configuration);
            if (recreate)
                schemaExport.Execute(false, true, true);
            schemaExport.Execute(false, true, false);
        }
开发者ID:hoghweed,项目名称:MyOverFlow,代码行数:10,代码来源:NHSupport.cs

示例3: CanCreate_FromScratch

        public void CanCreate_FromScratch()
        {
            SchemaExport schemaCreator = new SchemaExport(CreateConfiguration(xml1));
            schemaCreator.Execute((s) =>
                {
                    Debug.WriteLine(" === Create === ");
                    Debug.WriteLine(s);
                }, true, false);

            schemaCreator.Execute((s) =>
            {
                Debug.WriteLine(" === Drop === ");
                Debug.WriteLine(s);
            }, true, true);
        }
开发者ID:Jobu,项目名称:n2cms,代码行数:15,代码来源:UpgradeTest.cs

示例4: CreateDatabase

        public static void CreateDatabase()
        {
            CopyBlankDatabase();

            var export = new SchemaExport(NHibernateHelper.Configuration);
            export.Execute(true, true, false);
        }
开发者ID:dddcentral,项目名称:DeveloperDay,代码行数:7,代码来源:DatabaseUtilities.cs

示例5: Application_Start

        protected void Application_Start()
        {
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();

            var configuration = GlobalConfiguration.Configuration;

            var builder = new ContainerBuilder();
            builder.ConfigureWebApi(configuration);
            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.Register(c => CreateSessionFactory()).As<ISessionFactory>().SingleInstance();
            builder.Register(c =>
                {
                    var sf = c.Resolve<ISessionFactory>();
                    var session = sf.OpenSession();
                    var export = new SchemaExport(SavedConfig);
                    export.Execute(true, true, false, session.Connection, null);
                    return session;
                }
                ).As<ISession>().SingleInstance();

            builder.RegisterType<UnitOfWork>().InstancePerHttpRequest();
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            var resolver = new AutofacWebApiDependencyResolver(container);
            configuration.ServiceResolver.SetResolver(resolver);

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            BundleTable.Bundles.RegisterTemplateBundles();
        }
开发者ID:adbrowne,项目名称:Samples,代码行数:34,代码来源:Global.asax.cs

示例6: Execute

        public void Execute(Action<ISession> action)
        {
            var cfg = new SQLiteConfiguration()
                .InMemory()
                .ShowSql()
                .ConfigureProperties(new Configuration());

            // UGLY HACK
            var nhVersion = typeof(Configuration).Assembly.GetName().Version;
            if (!nhVersion.ToString().StartsWith("2.0."))
            {
                cfg.SetProperty("proxyfactory.factory_class",
                                "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
            }

            PersistenceModel.Configure(cfg);

            var sessionFactory = cfg.BuildSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var tx = session.BeginTransaction())
                {
                    SchemaExport export = new SchemaExport(cfg);
                    export.Execute(true, true, false, false, session.Connection, null);
                    tx.Commit();
                }

                using (var tx = session.BeginTransaction())
                {
                    action(session);
                    tx.Commit();
                }
            }
        }
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:35,代码来源:IntegrationTestHelper.cs

示例7: buildSchema

 private void buildSchema()
 {
     var cfg = NHibernateSessionProvider.Configuration;
     var schemaExport = new SchemaExport(cfg);
     //schemaExport.Create(false, true);
     schemaExport.Execute(false, true, false, Session.Connection, null);
 }
开发者ID:ztepsic,项目名称:DDD-IS-Housing-Mgmt,代码行数:7,代码来源:NHibernateFixture.cs

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

示例9: Main

        private static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            var log = LogManager.GetLogger(typeof (Program));

              SetupNHibernateValidator();

            var nhibernateConfig = new Configuration().Configure();
            nhibernateConfig.Initialize();

            ISessionFactory sessionFactory = nhibernateConfig.BuildSessionFactory();

            var schemaExport = new SchemaExport(nhibernateConfig);
            schemaExport.Execute(false, true, false);

            var junk = new Product
                       	{
                       		Name = "Spiffy Junk",
                       		Description = string.Empty,
                       		UnitPrice = -1M
                       	};

              var ve = Environment.SharedEngineProvider.GetEngine();
              var invalidValues = ve.Validate(junk);
              foreach (var invalidValue in invalidValues)
            log.InfoFormat("{0} {1}",
              invalidValue.PropertyName,
              invalidValue.Message);
        }
开发者ID:akhuang,项目名称:NHibernate,代码行数:29,代码来源:Program.cs

示例10: BuildSchema

 public static IDbConnection BuildSchema(ISession Session, Configuration configuration)
 {
     var export = new SchemaExport(configuration);
     var connection = Session.Connection;
     export.Execute(true, true, false, connection, null);
     return connection;
 }
开发者ID:RoyRV,项目名称:Training.MVC.Net,代码行数:7,代码来源:MapConfiguration.cs

示例11: SqlLiteBuilder

        public SqlLiteBuilder()
        {
            var showSql = GetShowSql();

            var configuration = new Configuration()
                .Proxy(p => p.ProxyFactoryFactory<DefaultProxyFactoryFactory>())
                .DataBaseIntegration(db =>
                {
                    db.Dialect<SQLiteDialect>();
                    db.Driver<SQLite20Driver>();
                    db.ConnectionString = "data source=:memory:";
                })
                .SetProperty(Environment.ReleaseConnections, "on_close")
                .SetProperty(Environment.ShowSql, showSql)
                .AddAssembly(Assembly.GetCallingAssembly());

            _sessionFactory = Fluently.Configure(configuration)
                .Mappings(mappings => mappings.FluentMappings.AddFromAssemblyOf<SqlLiteBuilder>())
                .BuildSessionFactory();

            _session = _sessionFactory.OpenSession();

            var textWriter = GetTextWriter();

            var schemaExport = new SchemaExport(configuration);

            schemaExport.Execute(false, true, false, _session.Connection, textWriter);
        }
开发者ID:chrisblock,项目名称:Criteria,代码行数:28,代码来源:SqlLiteBuilder.cs

示例12: NewsManagementInMemoryDatabaseFactory

 public NewsManagementInMemoryDatabaseFactory(ProvideInMemoryNewsManagementSessionFactoryInitialisation provideSessionFactoryInitialisation)
     : base(provideSessionFactoryInitialisation)
 {
     provideSessionFactoryInitialisation.InitialiseSessionFactory();
     SchemaExport export = new SchemaExport(provideSessionFactoryInitialisation.Configuration);
     export.Execute(true, true, false, Session.Connection, null);
 }
开发者ID:modulexcite,项目名称:framework-1,代码行数:7,代码来源:NewsManagementInMemoryDatabaseFactory.cs

示例13: CreateDB

        public void CreateDB()
        {
            SchemaExport schemaExport = new SchemaExport(Common.GetNHibernateConnnectInfo());
            schemaExport.Execute(false, true, false);

            CreateBlog();
        }
开发者ID:qianlifeng,项目名称:SQBlog,代码行数:7,代码来源:DBGenerate.cs

示例14: Create_a_database_schema_creation_script

 public void Create_a_database_schema_creation_script()
 {
     var export = new SchemaExport(_cfg);
     var sb = new StringBuilder();
     TextWriter output = new StringWriter(sb);
     export.Execute(true, false, false, false, null, output);
 }
开发者ID:tasluk,项目名称:hibernatingrhinos,代码行数:7,代码来源:CreateSchema_Fixture.cs

示例15: can_create_schema

 public void can_create_schema()
 {
     Configuration cfg = new NHibernate.Cfg.Configuration();
     SchemaExport exporter = new SchemaExport(cfg.Configure());
     exporter.Create(true, true);
     exporter.Execute(false, true, false, true);
 }
开发者ID:ignu,项目名称:tribality,代码行数:7,代码来源:LoadData.cs


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