Beispiel #1
0
        static SqlPreCommand SynchronizeProperties(Replacements rep)
        {
            var current = Administrator.TryRetrieveAll <PropertyRouteEntity>(rep).AgGroupToDictionary(a => a.RootType.FullClassName, g => g.ToDictionaryEx(f => f.Path, "PropertyEntity in the database with path"));

            var should = TypeLogic.TryEntityToType(rep).SelectDictionary(dn => dn.FullClassName, (dn, t) => GenerateProperties(t, dn).ToDictionaryEx(f => f.Path, "PropertyEntity in the database with path"));

            Table table = Schema.Current.Table <PropertyRouteEntity>();

            using (rep.WithReplacedDatabaseName())
                return(Synchronizer.SynchronizeScript(should, current,
                                                      null,
                                                      null,
                                                      (fullName, dicShould, dicCurr) =>
                                                      Synchronizer.SynchronizeScriptReplacing(rep, PropertiesFor.FormatWith(fullName),
                                                                                              dicShould,
                                                                                              dicCurr,
                                                                                              null,
                                                                                              (path, c) => table.DeleteSqlSync(c),
                                                                                              (path, s, c) =>
                {
                    c.Path = s.Path;
                    return table.UpdateSqlSync(c);
                }, Spacing.Simple),
                                                      Spacing.Double));
        }
Beispiel #2
0
        static SqlPreCommand SynchronizeProperties(Replacements rep)
        {
            var current = Administrator.TryRetrieveAll <PropertyRouteEntity>(rep).AgGroupToDictionary(a => a.RootType.CleanName, g => g.ToDictionaryEx(f => f.Path, "PropertyEntity in the database with path"));

            var should = TypeLogic.TryEntityToType(rep).SelectDictionary(dn => dn.CleanName, (dn, t) => GenerateProperties(t, dn).ToDictionaryEx(f => f.Path, "PropertyEntity in the database with path"));

            Table table = Schema.Current.Table <PropertyRouteEntity>();

            using (rep.WithReplacedDatabaseName())
                return(Synchronizer.SynchronizeScript(Spacing.Double, should, current,
                                                      createNew: null,
                                                      removeOld: null,
                                                      mergeBoth: (cleanName, dicShould, dicCurr) =>
                                                      Synchronizer.SynchronizeScriptReplacing(rep, PropertiesFor.FormatWith(cleanName), Spacing.Simple,
                                                                                              dicShould,
                                                                                              dicCurr,
                                                                                              createNew: null,
                                                                                              removeOld: (path, c) => table.DeleteSqlSync(c, p => p.RootType.CleanName == cleanName && p.Path == c.Path),
                                                                                              mergeBoth: (path, s, c) =>
                {
                    var originalPathName = c.Path;
                    c.Path = s.Path;
                    return table.UpdateSqlSync(c, p => p.RootType.CleanName == cleanName && p.Path == originalPathName);
                })
                                                      ));
        }