private static IAuxiliaryDatabaseObject CreateSimpleObject(HbmDatabaseObject databaseObjectSchema) { string createText = databaseObjectSchema.FindCreateText(); string dropText = databaseObjectSchema.FindDropText(); IAuxiliaryDatabaseObject simpleObject = new SimpleAuxiliaryDatabaseObject(createText, dropText); foreach (string dialectName in databaseObjectSchema.FindDialectScopeNames()) { simpleObject.AddDialectScope(dialectName); } return(simpleObject); }
public static void CreateHighLowTable(NHibernate.Cfg.Configuration config, HiloTable hiloTable) { StringBuilder stringBuilder1 = new StringBuilder(); stringBuilder1.AppendFormat("DELETE FROM {0};", (object)hiloTable.Name); stringBuilder1.AppendLine(); stringBuilder1.AppendFormat("ALTER TABLE {0} ADD {1} VARCHAR(128);", (object)hiloTable.Name, (object)hiloTable.TableNameColumn); stringBuilder1.AppendLine(); StringBuilder stringBuilder2 = new StringBuilder(); foreach (string str in Enumerable.Distinct <string>(Enumerable.Select <PersistentClass, string>(Enumerable.Where <PersistentClass>((IEnumerable <PersistentClass>)config.ClassMappings, (Func <PersistentClass, bool>)(m => m.IdentifierProperty.Type.ReturnedClass == typeof(long))), (Func <PersistentClass, string>)(m => m.Table.Name)))) { stringBuilder2.AppendFormat(string.Format("INSERT INTO [{0}] ({1}, {2}) VALUES ('{3}', 1);", (object)hiloTable.Name, (object)hiloTable.TableNameColumn, (object)hiloTable.NextHiColumn, (object)str), new object[0]); stringBuilder2.AppendLine(); } NHibernate.Cfg.Configuration configuration1 = config; string sqlCreateString1 = ((object)stringBuilder1).ToString(); // ISSUE: variable of the null type HashedSet <string> hashedSet1 = new HashedSet <string>(); hashedSet1.Add(typeof(MsSql2005Dialect).FullName); hashedSet1.Add(typeof(MsSql2008Dialect).FullName); hashedSet1.Add(typeof(MySQL5Dialect).FullName); hashedSet1.Add(typeof(SQLiteDialect).FullName); HashedSet <string> dialectScopes1 = hashedSet1; SimpleAuxiliaryDatabaseObject auxiliaryDatabaseObject1 = new SimpleAuxiliaryDatabaseObject(sqlCreateString1, (string)"", dialectScopes1); configuration1.AddAuxiliaryDatabaseObject((IAuxiliaryDatabaseObject)auxiliaryDatabaseObject1); NHibernate.Cfg.Configuration configuration2 = config; string sqlCreateString2 = ((object)stringBuilder2).ToString(); // ISSUE: variable of the null type HashedSet <string> hashedSet2 = new HashedSet <string>(); hashedSet2.Add(typeof(MsSql2005Dialect).FullName); hashedSet2.Add(typeof(MsSql2008Dialect).FullName); hashedSet2.Add(typeof(MySQL5Dialect).FullName); hashedSet2.Add(typeof(SQLiteDialect).FullName); HashedSet <string> dialectScopes2 = hashedSet2; SimpleAuxiliaryDatabaseObject auxiliaryDatabaseObject2 = new SimpleAuxiliaryDatabaseObject(sqlCreateString2, (string)"", dialectScopes2); configuration2.AddAuxiliaryDatabaseObject((IAuxiliaryDatabaseObject)auxiliaryDatabaseObject2); }
public static void AddClusteredIndexesWhereNeeded(this Configuration configuration) { string defaultCatalog = PropertiesHelper.GetString(Environment.DefaultCatalog, configuration.Properties, null); string defaultSchema = PropertiesHelper.GetString(Environment.DefaultSchema, configuration.Properties, null); var dialect = Dialect.GetDialect(configuration.Properties); var tables = (ICollection<Table>) tableMappingsProperty.GetValue(configuration, null); foreach (var table in tables) { var indexes = (Dictionary<string, Index>) indexesField.GetValue(table); if (table.HasPrimaryKey || indexes.Count != 1) { continue; } Index lonelyIndex = indexes.First().Value; indexes.Clear(); var clusteredIndexCreateSql = SqlCreateClusteredIndexString(dialect, lonelyIndex.Name, table, lonelyIndex.ColumnIterator, defaultCatalog, defaultSchema); var indexDropSql = lonelyIndex.SqlDropString(dialect, defaultCatalog, defaultSchema); var indexDbObject = new SimpleAuxiliaryDatabaseObject(clusteredIndexCreateSql, indexDropSql); configuration.AddAuxiliaryDatabaseObject(indexDbObject); } }