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


C# hbm2ddl.SchemaExport类代码示例

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


SchemaExport类属于NHibernate.Tool.hbm2ddl命名空间,在下文中一共展示了SchemaExport类的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: DatabaseRegistry

        public DatabaseRegistry()
        {
            var nHibernateConfiguration = new EmployeeApplicationNHibernateConfiguration();
            //string connectionString = ConfigurationManager.ConnectionStrings["EmployeeApplicationContext"].ConnectionString;

            ISessionFactory sessionFactory = Fluently
                .Configure()
                .Database(SQLiteConfiguration.Standard.UsingFile(@"sqlite.db"))
                //.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString))
                .Mappings(m =>
                          m.AutoMappings
                           .Add(AutoMap.AssemblyOf<Employee>(nHibernateConfiguration))
                )
                .ExposeConfiguration(cfg =>
                                     {
                                         var schemaExport = new SchemaExport(cfg);
                                         schemaExport.Drop(true, true);
                                         schemaExport.Create(true, true);
                                     })
                .BuildSessionFactory();

            For<ISessionFactory>().Singleton().Use(sessionFactory);
            For<ISession>().HybridHttpOrThreadLocalScoped().Use(ctx => ctx.GetInstance<ISessionFactory>().OpenSession());
            //TODO: Handle Tansactions For Application
            //For<IUnitOfWork>().CacheBy(new HybridLifecycle()).Use<UnitOfWork>();
        }
开发者ID:jeffxor,项目名称:NDUnitTesting,代码行数:26,代码来源:DatabaseRegistry.cs

示例3: Application_Start

        protected void Application_Start()
        {
            new Configurator().StartServer<Configurator>();

            var cfg = Simply.Do.GetNHibernateConfig();

            var check = new SchemaValidator(cfg);

            try
            {
                check.Validate();
            }
            catch
            {
                var exp = new SchemaExport(Simply.Do.GetNHibernateConfig());
                exp.Drop(true, true);
                exp.Create(true, true);

                using (Simply.Do.EnterContext())
                {
                    UserSample.Init();
                    GroupSample.Init();
                }
            }

            RegisterRoutes(RouteTable.Routes);
        }
开发者ID:juanplopes,项目名称:simple-telerik,代码行数:27,代码来源:Global.asax.cs

示例4: CreateSchemaExport

 private SchemaExport CreateSchemaExport(Configuration config)
 {
     var result = new SchemaExport(config);
     if (!string.IsNullOrEmpty(this.delimiter)) result.SetDelimiter(this.delimiter);
     if (!string.IsNullOrEmpty(this.outputFile)) result.SetOutputFile(this.outputFile);
     return result;
 }
开发者ID:night-king,项目名称:NHibernate-Shards,代码行数:7,代码来源:ShardedSchemaExport.cs

示例5: CreateDB

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

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

示例6: ExportSchema

 private static void ExportSchema(Configuration config)
 {
     var schema = new SchemaExport(config);
     // Auf false setzen, wenn kein neuer Account
     flushSchema = true;
     schema.Create(true, true);
 }
开发者ID:scrato,项目名称:RPA-RO_Business_Logic,代码行数:7,代码来源:SessionHelper.cs

示例7: Create

        /// <summary>
        /// Creata data base
        /// </summary>
        /// <returns><see cref="DataBase"/></returns>
        public DataBase Create()
        {
            var database = Connection.Database;

            Connection.ConnectionString = GetConnectionString();

            if (Dialect is MySQLDialect)
            {
                ExecuteCommand(string.Format("CREATE DATABASE IF NOT EXISTS {0};", database), Connection);
            }
            else if (Dialect is MsSql2000Dialect)
            {
                ExecuteCommand(string.Format("IF NOT(EXISTS(SELECT * FROM sys.sysdatabases where name='{0}')) BEGIN CREATE DATABASE {0}; END", database), Connection);
            }
            else if (Dialect is PostgreSQLDialect)
            {
                Connection.ChangeDatabase("postgres");

                ExecuteCommand(string.Format("CREATE DATABASE {0};", database), Connection);
            }

            Connection = ConnectionFactory.Factory(Configuration, Dialect);

            var schemaExport = new SchemaExport(SessionManager.Configuration);

            schemaExport.Create(false, true);

            return this;
        }
开发者ID:adrianocaldeira,项目名称:thunder,代码行数:33,代码来源:DataBase.cs

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

示例9: SessionExtensions_Usage_WorkingIsCorrect

        public void SessionExtensions_Usage_WorkingIsCorrect()
        {
            var configuration = Fluently.Configure();
            configuration.InitializeFromConfigSqLiteInMemory(true);
            configuration.AddMappingsFromAssemblyOf<UserMap>();

            Configuration config = null;
            configuration.ExposeConfiguration(c => config = c);
            var factory = configuration.BuildSessionFactory();
            var session = factory.OpenSession();

            var export = new SchemaExport(config);
            export.Execute(false, true, false, session.Connection, null);

            Assert.IsNull(session.GetObject<User>(x => x.Name == "test"));

            session.Save(new User { Name = "test" });
            session.Flush();

            var user = session.GetObject<User>(x => x.Name == "test");
            Assert.IsNotNull(user);

            user.Name = "foo";
            session.Update(user);
            session.Flush();

            user = session.GetObject<User>(x => x.Name == "foo");
            Assert.IsNotNull(user);

            session.Delete(user);
            session.Flush();
            Assert.IsNull(session.GetObject<User>(x => x.Name == "foo"));
        }
开发者ID:nora1879,项目名称:Simplify,代码行数:33,代码来源:SessionExtensionsTests.cs

示例10: HelloWorldStructureMapRegistry

        public HelloWorldStructureMapRegistry()
        {
            IncludeRegistry<ProAceCoreRegistry>();

            var sessionFactory = Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("HelloWorld")).ShowSql())
                .Mappings(m =>
                              {
                                  m.FluentMappings.AddFromAssemblyOf<MapMarker>();
                                  m.FluentMappings.Conventions.AddFromAssemblyOf<CollectionAccessConvention>();
                              })
                .ExposeConfiguration(cfg =>
                                         {
                                             var schemaExport = new SchemaExport(cfg);
                                             schemaExport.Drop(true, true);
                                             schemaExport.Create(true, true);
                                             For<NHibernate.Cfg.Configuration>().Use(cfg);
                                         })
                .BuildSessionFactory();

            For<ISessionFactory>()
                .Singleton()
                .Use(sessionFactory);

            For<ISession>()
                .Use(ctx => ctx.GetInstance<ISessionFactory>().OpenSession());

            For<IUserRepository>().Use<UserRepository>();
        }
开发者ID:jmlopez,项目名称:Integrator,代码行数:29,代码来源:HelloWorldStructureMapRegistry.cs

示例11: SQLiteInMemoryTestHelper

        /// <summary>
        /// Creates new instance of <see cref="SQLiteInMemoryTestHelper"/> on top of supplied Configuration
        /// </summary>
        /// <param name="configuration"></param>
        public SQLiteInMemoryTestHelper(Configuration configuration)
        {
            _configuration = configuration;

            _sessionFactory = configuration.BuildSessionFactory();
            _schemaExport = new SchemaExport(_configuration);
        }
开发者ID:solyutor,项目名称:enhima,代码行数:11,代码来源:SQLiteInMemoryTestHelper.cs

示例12: btnGenerateDBScript_Click

        private void btnGenerateDBScript_Click(object sender, RoutedEventArgs e)
        {
            Assembly assembly = Assembly.LoadFrom(txtFileName.Text);

            IPersistenceConfigurer databaseConfig = null;
            string fileName = "Domain Database Script - {0}.sql";

            if (rdbSqlServer.IsChecked != null)
                if (rdbSqlServer.IsChecked.Value)
                {
                    databaseConfig = MsSqlConfiguration.MsSql2005;
                    fileName = string.Format(fileName, "Sql Server 2005");
                }
                else if (rdbOracle.IsChecked != null)
                    if (rdbOracle.IsChecked.Value)
                    {
                        databaseConfig = OracleDataClientConfiguration.Oracle9;
                        fileName = string.Format(fileName, "Oracle 9g");
                    }

            Fluently.Configure()
                .Mappings(m => m.FluentMappings.AddFromAssembly(assembly))
                .Database(databaseConfig)//.ConnectionString("Data Source=.\\SQLEXPRESS;Initial Catalog=master;Integrated Security=True"))
                .ExposeConfiguration(config =>
                {
                    SchemaExport se = new SchemaExport(config);
                    se.SetOutputFile(fileName);
                    se.Create(false, false);
                    MessageBox.Show(string.Format("Script successful created! See the '{0}' file.", fileName));
                }).BuildConfiguration();
        }
开发者ID:tiagomaximo,项目名称:LiteFx,代码行数:31,代码来源:MainWindow.xaml.cs

示例13: BuildSchema

 private void BuildSchema(Configuration config)
 {
     SchemaExport schema = new SchemaExport(config);
     schema.Drop(this._criaScript, this._exportaScriptBD);
     schema.Create(this._criaScript, this._exportaScriptBD);
     config.SetInterceptor(new SqlStatementInterceptor());
 }
开发者ID:RMedeirosCosta,项目名称:eimbo,代码行数:7,代码来源:NHibernateHelper.cs

示例14: NHibernateManager

        /// <summary>
        /// Initiate NHibernate Manager
        /// </summary>
        /// <param name="connect">NHibernate dialect, driver and connection string separated by ';'</param>
        /// <param name="store">Name of the store</param>
        public NHibernateManager(string connect, string store)
        {
            try
            {
                ParseConnectionString(connect);

                //To create sql file uncomment code below and write the name of the file
                SchemaExport exp = new SchemaExport(configuration);
                exp.SetOutputFile("db_creation.sql");
                exp.Create(false, true);

                sessionFactory = configuration.BuildSessionFactory();

            }
            catch (MappingException mapE)
            {
                if (mapE.InnerException != null)
                    Console.WriteLine("[NHIBERNATE]: Mapping not valid: {0}, {1}, {2}", mapE.Message, mapE.StackTrace, mapE.InnerException.ToString());
                else
                    m_log.ErrorFormat("[NHIBERNATE]: Mapping not valid: {0}, {1}", mapE.Message, mapE.StackTrace);
            }
            catch (HibernateException hibE)
            {
                Console.WriteLine("[NHIBERNATE]: HibernateException: {0}, {1}", hibE.Message, hibE.StackTrace);
            }
            catch (TypeInitializationException tiE)
            {
                Console.WriteLine("[NHIBERNATE]: TypeInitializationException: {0}, {1}", tiE.Message, tiE.StackTrace);
            }
        }
开发者ID:jonnenauha,项目名称:ModreX,代码行数:35,代码来源:NHibernateManager.cs

示例15: BuildSchema

        private void BuildSchema(Configuration cfg)
        {
            var schemaExport = new SchemaExport(cfg);

            schemaExport.Drop(script: false, export: true);
            schemaExport.Create(script: false, export: true);
        }
开发者ID:uffekhansen,项目名称:FoosballGameManager,代码行数:7,代码来源:NHibernateBootstrapper.cs


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