Ejemplo n.º 1
0
        public void Execute()
        {
            // Wrap the upgrade in a single commit.
            using (
                IUpdateContext updateContext =
                    PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                UpdateContext context = updateContext as UpdateContext;
                if (context == null)
                {
                    Console.WriteLine("Unexpected error opening connection to the database.");
                    throw new ApplicationException("Error opening connection to the database.");
                }

                ExecuteSql(context, GetScript());

                DatabaseVersionUpdateColumns columns = new DatabaseVersionUpdateColumns();
                DatabaseVersionSelectCriteria criteria = new DatabaseVersionSelectCriteria();

                columns.Revision = DestinationVersion.Revision.ToString();
                columns.Build = DestinationVersion.Build.ToString();
                columns.Minor = DestinationVersion.Minor.ToString();
                columns.Major = DestinationVersion.Major.ToString();

                IDatabaseVersionEntityBroker broker = context.GetBroker<IDatabaseVersionEntityBroker>();
                broker.Update(criteria, columns);

                updateContext.Commit();
            }

            if (_upgradeStoredProcs)
            {
                RunSqlScriptApplication app = new RunSqlScriptApplication();
                app.RunApplication(new string[] {"-storedprocedures"});
            }
            return;
        }
 public DatabaseVersionSelectCriteria(DatabaseVersionSelectCriteria other)
     : base(other)
 {
 }
 public DatabaseVersionSelectCriteria(DatabaseVersionSelectCriteria other)
 : base(other)
 {}