Пример #1
0
        public override IEnumerable <string> SqlCommands <TKey>(CommandProvider <TKey> commandProvider, IDbConnection connection)
        {
            var fks = DependentForeignKeys ?? commandProvider.GetDependentForeignKeys(connection, TableInfo);

            foreach (var fk in fks)
            {
                yield return(commandProvider.DropForeignKeyCommand(fk));
            }

            yield return(commandProvider.DropTableCommand(TableInfo));
        }
        public override IEnumerable <string> SqlCommands <TKey>(CommandProvider <TKey> commandProvider, IDbConnection connection)
        {
            TableInfo tableInfo  = commandProvider.GetTableInfo(ModelType);
            var       rebuildFKs = commandProvider.GetDependentForeignKeys(connection, tableInfo);

            DropTable drop = new DropTable(tableInfo, rebuildFKs);

            foreach (var cmd in drop.SqlCommands(commandProvider, connection))
            {
                yield return(cmd);
            }

            CreateTable create = new CreateTable(ModelType);

            foreach (var cmd in create.SqlCommands(commandProvider, connection))
            {
                yield return(cmd);
            }

            foreach (var fk in rebuildFKs)
            {
                yield return(commandProvider.AddForeignKeyCommand(fk));
            }
        }