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


C# Configuration.GenerateSchemaCreationScript方法代码示例

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


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

示例1: SchemaExport

 /// <summary>
 /// Create a schema exporter for the given Configuration, with the given
 /// database connection properties
 /// </summary>
 /// <param name="cfg">The NHibernate Configuration to generate the schema from.</param>
 /// <param name="connectionProperties">The Properties to use when connecting to the Database.</param>
 public SchemaExport(Configuration cfg, IDictionary<string, string> connectionProperties)
 {
     this.connectionProperties = connectionProperties;
     dialect = Dialect.Dialect.GetDialect(connectionProperties);
     dropSQL = cfg.GenerateDropSchemaScript(dialect);
     createSQL = cfg.GenerateSchemaCreationScript(dialect);
 }
开发者ID:pallmall,项目名称:WCell,代码行数:13,代码来源:SchemaExport.cs

示例2: SchemaExport

		/// <summary>
		/// Create a schema exporter for the given Configuration, with the given
		/// database connection properties
		/// </summary>
		/// <param name="cfg">The NHibernate Configuration to generate the schema from.</param>
		/// <param name="configProperties">The Properties to use when connecting to the Database.</param>
		public SchemaExport(Configuration cfg, IDictionary<string, string> configProperties)
		{
			this.configProperties = configProperties;
			dialect = Dialect.Dialect.GetDialect(configProperties);
			dropSQL = cfg.GenerateDropSchemaScript(dialect);
			createSQL = cfg.GenerateSchemaCreationScript(dialect);
			formatter = (PropertiesHelper.GetBoolean(Environment.FormatSql, configProperties, true) ? FormatStyle.Ddl : FormatStyle.None).Formatter;
		}
开发者ID:pruiz,项目名称:nhibernate-old,代码行数:14,代码来源:SchemaExport.cs

示例3: ConfigurationIsOK

		public void ConfigurationIsOK()
		{
			Configuration cfg = new Configuration();
			cfg.AddResource("NHibernate.Test.NHSpecificTest.NH251.CustomAccessDO.hbm.xml",
			                Assembly.GetExecutingAssembly());

			ISessionFactoryImplementor factory = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
			cfg.GenerateSchemaCreationScript(factory.Dialect);
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:9,代码来源:CustomAccessFixture.cs

示例4: BuildSchema

        public void BuildSchema(ISession session, Configuration configuration)
        {
            IDbConnection connection = session.Connection;

            Dialect dialect = Dialect.GetDialect(configuration.Properties);
            string[] drops = configuration.GenerateDropSchemaScript(dialect);
            ExecuteScripts(drops, connection);

            string[] scripts = configuration.GenerateSchemaCreationScript(dialect);
            ExecuteScripts(scripts, connection);
        }
开发者ID:calebjenkins,项目名称:presentations,代码行数:11,代码来源:ConfigurationFactory.cs

示例5: ManyToManyTableCreationScript

		public void ManyToManyTableCreationScript()
		{
			Configuration cfg = new Configuration();
			Assembly assembly = Assembly.GetExecutingAssembly();
			cfg.AddResource( "NHibernate.Test.NHSpecificTest.NH257.Mappings.hbm.xml", assembly );
			
			string[] script = cfg.GenerateSchemaCreationScript(new Dialect.MsSql2000Dialect());
			string createManyToManyTable = script[1];
			Assert.AreEqual("create table users_in_groups (group_id INT not null, user_id INT not null, primary key (user_id, group_id))",
				createManyToManyTable);
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:11,代码来源:Fixture.cs

示例6: Main

        static void Main(string[] args)
        {
            Configuration cfg = new Configuration();
            
            cfg.Configure();
            
            string[] sqls = cfg.GenerateSchemaCreationScript(new MySQL5Dialect());

            File.WriteAllText("MySQL5SP.sql", string.Join(";\n", sqls));

            Console.WriteLine("OK");
        }
开发者ID:Ravivishnubhotla,项目名称:basewebframework,代码行数:12,代码来源:Program.cs

示例7: LiveSqliteSchema

 static LiveSqliteSchema()
 {
     var config = new Configuration();
     config.SetProperty(Environment.Dialect, "NHibernate.Dialect.SQLiteDialect");
     config.AddInputStream(HbmSerializer.Default.Serialize(Assembly.Load("tanzer.lotto.core")));
     Dialect dialect = Dialect.GetDialect(config.Properties);
     // pause at critical moments; row COUNT; rollback journal; isolation level
     // @sa http://www.sqlite.org/pragma.html
     script = "PRAGMA synchronous=FALSE;PRAGMA count_changes=FALSE;PRAGMA journal_mode=FALSE;PRAGMA read_uncommitted=TRUE;";
     script += String.Join(";", config.GenerateDropSchemaScript(dialect));
     script += ";";
     script += String.Join(";", config.GenerateSchemaCreationScript(dialect));
     script += ";";
 }
开发者ID:bjornebjornson,项目名称:LottoNh2,代码行数:14,代码来源:LiveSqliteSchema.cs

示例8: Bug

        public void Bug()
        {
            Configuration cfg = new Configuration();
            Assembly assembly = Assembly.GetExecutingAssembly();
            cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1594.Mappings.hbm.xml", assembly);

            string[] script = cfg.GenerateSchemaCreationScript(new MsSql2000Dialect());

            bool found = string.Compare(
                        script[0],
                        "create table A (id INT IDENTITY NOT NULL, Foo DECIMAL(4, 2) null, primary key (id))",
                        true) == 0;

            Assert.IsTrue(found, "when using decimal(precision,scale) Script should contain the correct create table statement");
        }
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:15,代码来源:Fixture.cs

示例9: ForeignKeyNames

		public void ForeignKeyNames()
		{
			Configuration cfg = new Configuration();
			Assembly assembly = Assembly.GetExecutingAssembly();
			cfg.AddResource( "NHibernate.DomainModel.MasterDetail.hbm.xml",
				Assembly.GetAssembly( typeof( NHibernate.DomainModel.Master ) )
				);
			

			string script = string.Join( "\n",
					cfg.GenerateSchemaCreationScript( new Dialect.MsSql2000Dialect() ) );

			Assert.IsTrue( script.IndexOf( "add constraint AA" ) >= 0 );
			Assert.IsTrue( script.IndexOf( "add constraint BB" ) >= 0 );
			Assert.IsTrue( script.IndexOf( "add constraint CC" ) >= 0 );
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:16,代码来源:Fixture.cs

示例10: DuplicateConstraints

		public void DuplicateConstraints()
		{
			Configuration cfg = new Configuration();
			cfg.AddResource(GetType().Namespace + ".Mappings.hbm.xml", GetType().Assembly);
			string[] script = cfg.GenerateSchemaCreationScript(new MsSql2000Dialect());

			int constraintCount = 0;
			foreach (string str in script)
			{
				if (str.IndexOf("foreign key (DependentVariableId) references NVariable") >= 0)
				{
					constraintCount++;
				}
			}
			Assert.AreEqual(1, constraintCount);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:16,代码来源:NH930Fixture.cs

示例11: TestMapElementElement

		public void TestMapElementElement()
		{
			var cfg = new Configuration().Configure();
			var mapper = new ModelMapper();

			mapper.Class<ClassWithMapElementElement>(c =>
				{
					c.Lazy(false);
					c.Id(id => id.Id, id =>
						{
							id.Generator(Generators.Identity);
						});

					c.Map(m => m.Map, col =>
						{
							col.Table("element_element");
							col.Key(k => k.Column("id"));
						}, key =>
						{
							key.Element(e =>
								{
									e.Column("key");
								});
						}, element =>
						{
							element.Element(e =>
								{
									e.Column("element");
								});
						});
				});

			cfg.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

			var script = cfg.GenerateSchemaCreationScript(new MsSql2012Dialect());

			Assert.False(script.Any(x => x.Contains("idx")));
		}
开发者ID:liypeng,项目名称:nhibernate-core,代码行数:38,代码来源:MapFixture.cs

示例12: ManyToManyTableCreationScript

		public void ManyToManyTableCreationScript()
		{
			Configuration cfg = new Configuration();
			Assembly assembly = Assembly.GetExecutingAssembly();
			cfg.AddResource("NHibernate.Test.NHSpecificTest.NH257.Mappings.hbm.xml", assembly);

			string[] script = cfg.GenerateSchemaCreationScript(new MsSql2000Dialect());

			bool found = false;

			foreach (string line in script)
			{
				if (string.Compare(
				    	line,
				    	"create table users_in_groups (group_id INT not null, user_id INT not null, primary key (user_id, group_id))",
				    	true) == 0)
				{
					found = true;
				}
			}

			Assert.IsTrue(found, "Script should contain the correct create table statement");
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:23,代码来源:Fixture.cs

示例13: Main

        static int Main(string[] args)
        {
            try
            {
                log4net.Config.XmlConfigurator.Configure();
                string scriptDir = Settings.Default.ScriptsDir;
                if (!Path.IsPathRooted (scriptDir))
                {
                    scriptDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, scriptDir);
                }

                Console.WriteLine("Generating script...");

                Configuration cfg = new Configuration();
                cfg.Configure();

                Dialect dialect = Dialect.GetDialect(cfg.Properties);
                string[] dropStatements = cfg.GenerateDropSchemaScript(dialect);
                string[] createStatements = cfg.GenerateSchemaCreationScript(dialect);

                using (StreamWriter writer = new StreamWriter(Path.Combine(scriptDir, Settings.Default.ScriptToGenerate), false, Encoding.Default))
                {
                    foreach (string s in dropStatements)
                    {
                        string f = Format(ParseDropConstraint(s));
                        writer.WriteLine(f);
                    }

                    writer.WriteLine();

                    foreach (string s in createStatements)
                    {
                        string f = Format(ParseCreateTable(s));
                        writer.WriteLine(f);
                    }

                    foreach (string scriptToAppend in Settings.Default.ScriptsToAppend)
                    {
                        writer.WriteLine();
                        writer.WriteLine(File.ReadAllText(Path.Combine(scriptDir, scriptToAppend),Encoding.Default));
                    }
                }
                Console.WriteLine("Done");
            }
            catch (Exception e)
            {
                log.Error(e);
                Console.WriteLine(e);
                return 1;
            }

            return 0;
        }
开发者ID:andreyu,项目名称:Reports,代码行数:53,代码来源:Program.cs

示例14: CreateFile

        public static System.Data.IDbConnection CreateFile (string path)
        {
            lock (mutex)
                if (newSession == null)
                {
                    Configuration configuration = new Configuration()
                        .SetProperty("dialect", typeof(CustomSQLiteDialect).AssemblyQualifiedName)
                        .SetProperty("connection.connection_string", "Data Source=:memory:;Version=3;")
                        .SetProperty("connection.driver_class", typeof(NHibernate.Driver.SQLite20Driver).AssemblyQualifiedName)
                        .SetProperty("connection.provider", typeof(NHibernate.Connection.DriverConnectionProvider).AssemblyQualifiedName)
                        .SetProperty("connection.release_mode", "on_close")
                        ;

                    ConfigureMappings(configuration);

                    var sessionFactory = configuration.BuildSessionFactory();
                    newSession = sessionFactory.OpenStatelessSession();
                    createSql = configuration.GenerateSchemaCreationScript(Dialect.GetDialect(configuration.Properties));
                }

            string uncCompatiblePath = Util.GetSQLiteUncCompatiblePath(path);
            bool pooling = false;// path == ":memory:";
            var conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;{1}", uncCompatiblePath, (pooling ? "Pooling=True;Max Pool Size=1;" : "")));
            conn.Open();

            var journal_mode = conn.ExecuteQuery("PRAGMA journal_mode").Single()[0];
            var synchronous = conn.ExecuteQuery("PRAGMA synchronous").Single()[0];
            conn.ExecuteNonQuery(@"PRAGMA journal_mode=OFF;
                                   PRAGMA synchronous=OFF;
                                   PRAGMA automatic_indexing=OFF;
                                   PRAGMA cache_size=30000;
                                   PRAGMA temp_store=MEMORY;
                                   PRAGMA page_size=32768;
                                   PRAGMA mmap_size=70368744177664; -- 2^46");

            var transaction = conn.BeginTransaction();
            var cmd = conn.CreateCommand();
            foreach (string sql in createSql)
                cmd.ExecuteNonQuery(sql);

            cmd.ExecuteNonQuery(String.Format("INSERT INTO About VALUES (1, 'IDPicker', '{0}', datetime('now'), {1})",
                                              Util.Version, SchemaUpdater.CurrentSchemaRevision));

            cmd.ExecuteNonQuery(@"CREATE TABLE PeptideSpectrumMatchScoreName (Id INTEGER PRIMARY KEY, Name TEXT UNIQUE NOT NULL);
                                  CREATE TABLE DistinctMatchQuantitation (Id TEXT PRIMARY KEY, iTRAQ_ReporterIonIntensities BLOB, TMT_ReporterIonIntensities BLOB, PrecursorIonIntensity NUMERIC);
                                  CREATE TABLE IntegerSet (Value INTEGER PRIMARY KEY);");
            CreateIndexes(conn);
            transaction.Commit();

            conn.ExecuteNonQuery("PRAGMA journal_mode=" + journal_mode + ";" +
                                 "PRAGMA synchronous=" + synchronous);

            return conn;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:54,代码来源:SessionFactoryFactory.cs

示例15: ExportCreateSchema

 public static string[] ExportCreateSchema(Dialect dialect)
 {
     Configuration cfg = new Configuration();
     cfg.Configure();
     return cfg.GenerateSchemaCreationScript(dialect);
 }
开发者ID:Ravivishnubhotla,项目名称:basewebframework,代码行数:6,代码来源:SchemaHelper.cs


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