Class MergeReturningBuilder<TEntity, TResult>
Fluent terminal for a full MERGE that returns the merged rows through the provider's
OUTPUT/RETURNING form, started with
Returning() or
Returning<TResult>(Expression<Func<TEntity, TResult>>).
The returned rows are materialised with the same projection pipeline as a query; every terminal reads
the result through Single() or ToList().
public sealed class MergeReturningBuilder<TEntity, TResult>
Type Parameters
TEntityThe mapped entity type merged.
TResultThe materialized row type (the entity or a projection).
- Inheritance
-
MergeReturningBuilder<TEntity, TResult>
- Inherited Members
- Extension Methods
Methods
Single()
Executes the merge and returns the single merged row.
public TResult Single()
Returns
- TResult
The materialized row.
Exceptions
- InvalidOperationException
The merge touched no row, or more than one; use ToList().
- NotSupportedException
The provider cannot return merged rows, or the context is read-only.
SingleAsync(CancellationToken)
Asynchronously executes the merge and returns the single merged row.
public Task<TResult> SingleAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels execution.
Returns
- Task<TResult>
A task producing the materialized row.
Exceptions
- InvalidOperationException
The merge touched no row, or more than one; use ToListAsync(CancellationToken).
- NotSupportedException
The provider cannot return merged rows, or the context is read-only.
ToList()
Executes the merge and returns every merged row.
public IReadOnlyList<TResult> ToList()
Returns
- IReadOnlyList<TResult>
The materialized rows, in result-set order.
Exceptions
- NotSupportedException
The provider cannot return merged rows, or the context is read-only.
ToListAsync(CancellationToken)
Asynchronously executes the merge and returns every merged row.
public Task<IReadOnlyList<TResult>> ToListAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancels execution.
Returns
- Task<IReadOnlyList<TResult>>
A task producing the materialized rows, in result-set order.
Exceptions
- NotSupportedException
The provider cannot return merged rows, or the context is read-only.
ToSql()
Renders the parameterised SQL this builder 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.
Exceptions
- NotSupportedException
The context is not database-backed (for example the in-memory provider), or the provider cannot return merged rows.