當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。