Class OutputIntoBuilder
Fluent terminal for an INSERT/UPDATE/DELETE whose modified rows are written into a
target through SQL Server's OUTPUT ... INTO <target>(columns) clause instead of being
returned to the client. Started with OutputInto(...) or OutputIntoTableVariable(...) on an
InsertReturningBuilder<TEntity, TResult>, UpdateReturningBuilder<TEntity, TResult>
or DeleteReturningBuilder<TEntity, TResult>.
The builder deliberately has no row terminals: nothing is returned to the client, so
Execute() reports the affected-row count and ToSql() renders the statement.
To also return the rows to the client, use the separate OutputIntoThenOutput(...) form.
The target is either an explicit table name that must already exist, or a table variable declared in the same batch. In both forms the selected output columns are reused as the target column list, so the target columns must have the same names as the selected output columns. A table variable additionally takes a caller-supplied, trusted column-definition text; the declaration text is embedded verbatim and never parameterised.
public sealed class OutputIntoBuilder
- Inheritance
-
OutputIntoBuilder
- Inherited Members
- Extension Methods
Methods
Execute()
Executes the statement and returns the number of rows written into the target.
public int Execute()
Returns
- int
The number of affected rows, as reported by the provider.
Exceptions
- NotSupportedException
The provider cannot express
OUTPUT ... INTO, or the context is read-only.
ExecuteAsync(CancellationToken)
Asynchronously executes the statement and returns the number of rows written into the target.
public Task<int> ExecuteAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels execution.
Returns
Exceptions
- NotSupportedException
The provider cannot express
OUTPUT ... INTO, or the context is read-only.
ToSql()
Renders the parameterised SQL this statement would execute, without executing it. Useful for diagnostics and for verifying SQL generation without a database.
public string ToSql()
Returns
- string
The rendered SQL text.