本文整理汇总了C#中DatabaseVersion.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseVersion.IsNull方法的具体用法?C# DatabaseVersion.IsNull怎么用?C# DatabaseVersion.IsNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseVersion
的用法示例。
在下文中一共展示了DatabaseVersion.IsNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DowngradeDatabase
private void DowngradeDatabase(IEnumerable<IScript> migrationScripts, DatabaseVersion currentVersion, long? targetVersionNumber, IScriptRunner scriptRunner, string schema)
{
var applicableScripts = migrationScripts.Where(s => currentVersion.IsNull() || s.Version <= currentVersion.Version)
.Where(s => !targetVersionNumber.HasValue || s.Version > targetVersionNumber).ToArray();
if (applicableScripts.IsNullOrEmpty())
{
Output.Warn("No migration scripts need to be run. Nothing will be done.");
}
else
{
Output.Info("The following scripts will be applied to the database:");
foreach (var script in applicableScripts)
{
Output.Info(script.Name, 1);
}
Output.EmptyLine();
Prompt.ForAnyKey("Press any key to start the 'down' migration. Ctrl-C to abort.");
foreach (var script in applicableScripts)
{
Output.Info("Executing script: {0}".FormatWith(script.Path));
try
{
scriptRunner.Execute(script);
}
catch (SqlPlusException)
{
if (!_force)
{
throw;
}
}
Output.Info("Script '{0}' completed.".FormatWith(script.Name));
Output.Text("Removing script contents for script '{0}' from applied scripts table".FormatWith(script.Name));
_appliedScriptsRepository.RemoveAppliedScript(script.AsDatabaseVersion(), schema);
Output.Text("Removing version {0} for script '{1}' from version table".FormatWith(script.Version, script.Name));
_versionRespository.RemoveVersion(script.AsDatabaseVersion(), schema);
}
}
}