Class BulkInsertOptionsBuilder
Fluent builder for BulkInsertOptions. Every setter validates immediately and returns the builder, so an invalid option fails at the call site rather than at execution.
public sealed class BulkInsertOptionsBuilder
- Inheritance
-
BulkInsertOptionsBuilder
- Inherited Members
- Extension Methods
Methods
Build()
Builds the immutable options.
public BulkInsertOptions Build()
Returns
- BulkInsertOptions
The configured options.
CheckConstraints(bool)
Checks CHECK and FOREIGN KEY constraints during the write (SQL Server native path only).
public BulkInsertOptionsBuilder CheckConstraints(bool value = true)
Parameters
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
ClickHouse(ClickHouseBulkInsertOptions)
Supplies the ClickHouse native options group.
public BulkInsertOptionsBuilder ClickHouse(ClickHouseBulkInsertOptions options)
Parameters
optionsClickHouseBulkInsertOptionsThe ClickHouse options; must not be null.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentNullException
optionsis null.
Database(string)
Overrides the database part of the destination.
public BulkInsertOptionsBuilder Database(string database)
Parameters
databasestringThe database name; must not be empty.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentException
databaseis null or empty.
FireTriggers(bool)
Fires INSERT triggers for the written rows (SQL Server native path only).
public BulkInsertOptionsBuilder FireTriggers(bool value = true)
Parameters
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
IgnoreDuplicates(bool)
Skips rows that violate a unique constraint. Honoured where either path can express it (the native provider load or the portable statement); a provider where neither can refuses the request by name instead of writing the rows as a plain insert, and an explicit Native refuses it rather than silently dropping the option.
public BulkInsertOptionsBuilder IgnoreDuplicates(bool value = true)
Parameters
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
KeepIdentity(bool)
Writes explicit values to identity columns. The path stays capability based: Auto uses the native path where it can honour the option and the portable path otherwise, Native refuses the request by name instead of dropping the option, and Portable selects the portable path explicitly.
public BulkInsertOptionsBuilder KeepIdentity(bool value = true)
Parameters
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
KeepNulls(bool)
Writes explicit null values instead of the destination DEFAULT (SQL Server native path only).
public BulkInsertOptionsBuilder KeepNulls(bool value = true)
Parameters
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
MaxBatchSize(int)
Limits the rows written per statement (the portable path chunks; the native path treats it as a batch hint or ignores it).
public BulkInsertOptionsBuilder MaxBatchSize(int rows)
Parameters
rowsintThe maximum rows per statement; must be positive.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentOutOfRangeException
rowsis not positive.
MaxParameters(int)
Limits the bound parameters per statement on the portable path.
public BulkInsertOptionsBuilder MaxParameters(int count)
Parameters
countintThe maximum parameters per statement; must be positive.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentOutOfRangeException
countis not positive.
MaxSqlLength(int)
Limits the approximate SQL text length per statement on the portable path.
public BulkInsertOptionsBuilder MaxSqlLength(int characters)
Parameters
charactersintThe approximate maximum SQL length; must be positive.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentOutOfRangeException
charactersis not positive.
Mode(BulkInsertMode)
Selects the execution path.
public BulkInsertOptionsBuilder Mode(BulkInsertMode mode)
Parameters
modeBulkInsertModeThe requested mode; must be a defined BulkInsertMode value.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentOutOfRangeException
modeis undefined.
NotifyAfter(int, Action<int, CancellationToken>)
Reports progress with the cumulative written-row count every rows rows.
public BulkInsertOptionsBuilder NotifyAfter(int rows, Action<int, CancellationToken> onRows)
Parameters
rowsintThe reporting interval in rows; must be positive.
onRowsAction<int, CancellationToken>Called with the cumulative written-row count and the progress cancellation token.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentNullException
onRowsis null.- ArgumentOutOfRangeException
rowsis not positive.
ProgressCancellationTokenSource(CancellationTokenSource)
Supplies the token passed to the NotifyAfter(int, Action<int, CancellationToken>) callback, enabling cooperative
time-limiting (source.CancelAfter(timeout)). The source is owned by the caller.
public BulkInsertOptionsBuilder ProgressCancellationTokenSource(CancellationTokenSource source)
Parameters
sourceCancellationTokenSourceThe source whose token the callback observes.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentNullException
sourceis null.
Schema(string)
Overrides the schema part of the destination, keeping the mapped or explicit table.
public BulkInsertOptionsBuilder Schema(string schema)
Parameters
schemastringThe schema name; must not be empty.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentException
schemais null or empty.
Server(string)
Overrides the server part of the destination where the provider/path supports server qualification.
public BulkInsertOptionsBuilder Server(string server)
Parameters
serverstringThe server name; must not be empty.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentException
serveris null or empty.
SqlServer(SqlServerBulkInsertOptions)
Supplies the SQL Server native options group.
public BulkInsertOptionsBuilder SqlServer(SqlServerBulkInsertOptions options)
Parameters
optionsSqlServerBulkInsertOptionsThe SQL Server options; must not be null.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentNullException
optionsis null.
Table(string)
Overrides the target table for this write. The naming convention is not applied to an explicit target; use the two-argument Table(string, string) overload to qualify it with a schema.
public BulkInsertOptionsBuilder Table(string table)
Parameters
tablestringThe destination table name; must not be empty.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentException
tableis null or empty.
Table(string, string)
Overrides the target table for this write and qualifies it with a schema (or database).
public BulkInsertOptionsBuilder Table(string schema, string table)
Parameters
schemastringThe schema (or database) name; must not be empty.
tablestringThe destination table name; must not be empty.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentException
schemaortableis null or empty.
TableLock(bool)
Takes a table-level bulk-update lock for the duration of the write (SQL Server native path only).
public BulkInsertOptionsBuilder TableLock(bool value = true)
Parameters
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
TargetKind(BulkInsertTargetKind)
Selects the kind of destination table.
public BulkInsertOptionsBuilder TargetKind(BulkInsertTargetKind kind)
Parameters
kindBulkInsertTargetKindThe requested target kind; must be a defined BulkInsertTargetKind value.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentOutOfRangeException
kindis undefined.
Timeout(TimeSpan)
Sets the whole-invocation timeout budget (all paths), measured from execution entry.
public BulkInsertOptionsBuilder Timeout(TimeSpan timeout)
Parameters
timeoutTimeSpanThe budget; must be positive.
Returns
- BulkInsertOptionsBuilder
This builder, for chaining.
Exceptions
- ArgumentOutOfRangeException
timeoutis zero or negative.