具有操作参数的电源外壳方法<T>



如何执行将Action<T>作为PowerShell中参数的方法?

upgradeEngine.Configure(c => c.ScriptExecutor.ExecutionTimeoutSeconds = 15 * 60);

c#代码:

var upgradeEngine = DeployChanges.To
    .SqlDatabase(connectionString)
    .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
    .LogToConsole();
//this line
upgradeEngine.Configure(c => c.ScriptExecutor.ExecutionTimeoutSeconds = 15 * 60);
//this line
upgradeEngine.Build();
Add-Type -Path (Join-Path -Path $currentPath -ChildPath 'x:locationofDbUp.dll')
$dbUp = [DbUp.DeployChanges]::To
$dbUp = [SqlServerExtensions]::SqlDatabase($dbUp, $connectionString)
$dbUp = [StandardExtensions]::WithScriptsFromFileSystem($dbUp, $scriptPath)
$dbUp = [StandardExtensions]::LogToConsole($dbUp)
$upgradeResult = $dbUp.Build().PerformUpgrade()

构建具有适当签名的脚本块,并将其施放为[Action[T]]

$delegate = [System.Action[DbUp.Builder.UpgradeConfiguration]]{
  param([DbUp.Builder.UpgradeConfiguration]$c)
  $c.ScriptExecutor.ExecutionTimeoutSeconds = 15 * 60
}
$DbUp.Configure($delegate)

相关内容

  • 没有找到相关文章