Beispiel #1
0
        public static SqlPreCommand Schema_Synchronizing(Replacements replacements)
        {
            Table table = Schema.Current.Table <TypeEntity>();

            Dictionary <string, TypeEntity> should = GenerateSchemaTypes().ToDictionaryEx(s => s.TableName, "tableName in memory");

            Dictionary <string, TypeEntity> current = replacements.ApplyReplacementsToOldCleaning(
                Administrator.TryRetrieveAll <TypeEntity>(replacements).ToDictionaryEx(c => c.TableName, "tableName in database"), Replacements.KeyTables);

            using (replacements.WithReplacedDatabaseName())
                return(Synchronizer.SynchronizeScript(
                           should,
                           current,
                           (tn, s) => table.InsertSqlSync(s),
                           (tn, c) => table.DeleteSqlSync(c),
                           (tn, s, c) =>
                {
                    var originalName = c.FullClassName;

                    c.TableName = s.TableName;
                    c.CleanName = s.CleanName;
                    c.Namespace = s.Namespace;
                    c.ClassName = s.ClassName;
                    return table.UpdateSqlSync(c, comment: originalName);
                }, Spacing.Double));
        }