当前位置: 首页>>代码示例>>C#>>正文


C# DatabaseVersion.IsNull方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:plmwong,项目名称:soothsayer,代码行数:46,代码来源:DownMigration.cs


注:本文中的DatabaseVersion.IsNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。