Definition at line 33 of file DatabaseUpdater.cs.
Definition at line 35 of file DatabaseUpdater.cs.
References factory.
39 changes =
new List<IVersionChanges>();
readonly ISqlFactory factory
readonly List< IVersionChanges > changes
void Ntp.Data.Schema.DatabaseUpdater.ApplyChanges |
( |
| ) |
|
|
inline |
Definition at line 62 of file DatabaseUpdater.cs.
References c, e, and version.
64 var controller =
new VersionController(
factory,
log);
65 int databaseVersion = controller.FindCurrentVersion();
67 if (databaseVersion <= 0)
69 var last =
changes.OrderBy(
c =>
c.VersionNumber).LastOrDefault();
71 controller.SetCurrentVersion(last);
76 IVersionChanges lastVersion = null;
78 OrderBy(
c =>
c.VersionNumber).
79 Where(
c =>
c.VersionNumber > databaseVersion);
81 var changeList = versionChanges.ToList();
82 if (changeList.Count == 0)
88 log.ApplySchemaChanges();
93 foreach (var
version in changeList)
95 var transaction = connection.BeginTransaction();
98 foreach (var change
in version)
101 command.Connection = connection;
102 command.CommandText = change.Sql;
103 command.Transaction = transaction;
105 log.SqlExecute(command.CommandText);
106 command.ExecuteNonQuery();
108 transaction.Commit();
112 log.SchemaUpdateError(e);
113 transaction.Rollback();
118 log.SchemaChangesApplied(lastVersion.VersionText);
121 if (connection.State == ConnectionState.Open)
124 controller.SetCurrentVersion(lastVersion);
IDbConnection CreateConnection()
readonly ISqlFactory factory
IDbCommand CreateCommand()
readonly List< IVersionChanges > changes
bool Ntp.Data.Schema.DatabaseUpdater.CheckLatestVersion |
( |
| ) |
|
|
inline |
Definition at line 127 of file DatabaseUpdater.cs.
References c.
129 var controller =
new VersionController(
factory,
log);
130 int databaseVersion = controller.FindCurrentVersion();
131 var latest =
changes.OrderBy(
c =>
c.VersionNumber).Last();
133 if (databaseVersion == -1)
135 controller.SetCurrentVersion(latest);
139 if (databaseVersion == latest.VersionNumber)
142 log.SchemaVersionError(databaseVersion, latest.VersionNumber);
readonly ISqlFactory factory
readonly List< IVersionChanges > changes
IEnumerator IEnumerable. Ntp.Data.Schema.DatabaseUpdater.GetEnumerator |
( |
| ) |
|
|
inlineprivate |
IEnumerator<IVersionChanges> Ntp.Data.Schema.DatabaseUpdater.GetEnumerator |
( |
| ) |
|
|
inline |
readonly ISqlFactory Ntp.Data.Schema.DatabaseUpdater.factory |
|
private |
readonly LogBase Ntp.Data.Schema.DatabaseUpdater.log |
|
private |
The documentation for this class was generated from the following file: