DuckDbStatementBuilder
A class used to build the SQL statements for DuckDB.
This class is the BaseStatementBuilder-derived implementation for DuckDB. It is automatically registered by DuckDbBootstrap — you do not need to instantiate it directly under normal use.
Constructors
public DuckDbStatementBuilder()
public DuckDbStatementBuilder(IDbSetting dbSetting,
IResolver<Field, IDbSetting, string> convertFieldResolver = null,
IResolver<Type, Type> averageableClientTypeResolver = null)
The parameterless constructor resolves dbSetting via DbSettingMapper.Get<DuckDBConnection>(), so it can only be used after DuckDbBootstrap has run.
DuckDB-specific generation notes
- Paging uses
LIMIT/LIMIT ... OFFSETfor BatchQuery/skip-take queries and top-N Query. - Insert appends a
RETURNING <key> AS "Result"clause onto the same statement, so the generated key comes back from the one round trip instead of a separate identity-lookup call. - InsertAll builds a single multi-row
VALUES (...), (...), ...statement with one trailingRETURNINGclause — DuckDB returns the generated keys in the same order the rows were listed, so the whole batch is inserted and its keys retrieved in a single round trip. - Merge/MergeAll are compiled as
INSERT ... ON CONFLICT (<qualifiers>) DO UPDATE SET ... RETURNING ...(DuckDB’s native upsert).
MergeAll packs
batchSizeof those statements into a single command text (one round trip for the whole batch). DuckDB’s binder rejects any parameter reference inside aRETURNINGprojection outright, so the row’s ordinal position — normally passed as a bound__RepoDb_OrderColumn_{index}parameter — is instead embedded as an integer literal directly in each statement’sRETURNINGclause; the unused parameter is simply left unbound.
Usability
Use StatementBuilderMapper to override it with a custom implementation.
StatementBuilderMapper.Add(typeof(DuckDBConnection), new MyCustomDuckDbStatementBuilder(dbSetting), true);