Sources/Object/Update-Object.ps1
|
using namespace Belin.Sql using namespace System.Data using namespace System.Diagnostics.CodeAnalysis <# .SYNOPSIS Updates the specified entity. .INPUTS The entity to update. .OUTPUTS The number of rows affected. #> function Update-Object { [CmdletBinding()] [OutputType([int])] [SuppressMessage("PSUseShouldProcessForStateChangingFunctions", "")] param ( # The connection to the data source. [Parameter(Mandatory, Position = 0)] [IDbConnection] $Connection, # The entity to update. [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [object] $InputObject, # An optional command builder used to build the SQL query to be executed. [SqlCommandBuilder] $Builder, # The list of columns to update. By default, all columns. [ValidateNotNull()] [string[]] $Columns = @(), # The wait time, in seconds, before terminating the attempt to execute the command and generating an error. [ValidateRange("NonNegative")] [int] $Timeout = 30, # The transaction within which the command executes. [IDbTransaction] $Transaction ) begin { $Builder ??= New-CommandBuilder $Connection } process { [DbConnectionExtensions]::Update($Connection, $InputObject, $Columns, $Timeout, $Transaction, $Builder) } } |