コード例 #1
0
        public static void SchemaCreate(global::NHibernate.Cfg.Configuration config)
        {
            var script = new StringBuilder();

            script.AppendFormat("DELETE FROM {0};", HiLoIdentityTableName);
            script.AppendLine();
            script.AppendFormat("ALTER TABLE {0} ADD COLUMN {1} VARCHAR(128) NOT NULL;", HiLoIdentityTableName, TableColumnName);
            script.AppendLine();
            script.AppendFormat("CREATE INDEX ix_{0}_{1} ON {0} (Entity);", HiLoIdentityTableName, TableColumnName);
            script.AppendLine();

            foreach (var entityName in config.ClassMappings.Select(m => m.MappedClass != null ? m.MappedClass.Name : m.Table.Name).Distinct())
            {
                script.AppendFormat("INSERT INTO {0} ({1}, {2}) VALUES ('[{3}]', 0);", HiLoIdentityTableName, TableColumnName, NextHiValueColumnName, entityName);
                script.AppendLine();
            }

            config.AddAuxiliaryDatabaseObject(new SimpleAuxiliaryDatabaseObject(script.ToString(), null, ValidDialects));
        }
コード例 #2
0
        public static void SchemaCreate(global::NHibernate.Cfg.Configuration config)
        {
            var script = new StringBuilder();

            script.AppendFormat("DELETE FROM {0};", HiLoIdentityTableName);
            script.AppendLine();
            script.AppendFormat("ALTER TABLE {0} ADD COLUMN {1} VARCHAR(128) NOT NULL;", HiLoIdentityTableName, TableColumnName);
            script.AppendLine();
            script.AppendFormat("CREATE INDEX ix_{0}_{1} ON {0} (Entity);", HiLoIdentityTableName.Replace("public.", ""), TableColumnName);
            script.AppendLine();

            var fullNames = FullNames.Values.ToList();

            foreach (var entityName in fullNames)
            {
                script.AppendFormat("INSERT INTO {0} ({1}, {2}) VALUES ('{3}', 0);", HiLoIdentityTableName, TableColumnName, NextHiValueColumnName, entityName);
                script.AppendLine();
            }

            config.AddAuxiliaryDatabaseObject(new SimpleAuxiliaryDatabaseObject(script.ToString(), null, ValidDialects));
        }