FirebirdStatementBuilder
This class is the BaseStatementBuilder-derived implementation for Firebird. It targets Firebird 3.0 and later, and is automatically registered by FirebirdBootstrap — you do not need to instantiate it directly under normal use.
Constructors
public FirebirdStatementBuilder()
public FirebirdStatementBuilder(IDbSetting dbSetting,
IResolver<Field, IDbSetting, string> convertFieldResolver = null,
IResolver<Type, Type> averageableClientTypeResolver = null)
convertFieldResolver defaults to FirebirdConvertFieldResolver, used to render CAST(...) expressions for typed fields.
Firebird-specific generation notes
- Paging uses
FIRST n(top-N Query/Exists) andFIRST m SKIP n(for BatchQuery/skip-take queries), written directly afterSELECT— Firebird has noTOP/LIMITkeyword. - Insert excludes the identity column from the column list (letting
GENERATED ALWAYS/BY DEFAULT AS IDENTITYauto-populate it) and appends aRETURNING <key> AS "Result"clause, which Firebird’sRETURNINGonINSERTnatively surfaces as an ordinary single-row result set — no PL/SQL block or output-parameter wrapping is required, unlike Oracle. - InsertAll reuses the single-row Insert statement (
batchSizeof1); abatchSizegreater than1throwsNotSupportedException, sinceFirebirdDbSetting.IsMultiStatementExecutableisfalse. - Merge compiles to Firebird’s native
UPDATE OR INSERT INTO ... MATCHING (...) RETURNING ...upsert statement — the closest single-statement shape to MySQL’sON DUPLICATE KEY UPDATE/PostgreSQL’sON CONFLICT DO UPDATE. When the identity column is itself a qualifier,UPDATE OR INSERT’sMATCHINGcannot reliably match a not-yet-inserted row, so the builder instead emits anEXECUTE BLOCK(Firebird’s inline PL/SQL construct) that branches:INSERTwhen the identity parameter isNULL/0, otherwiseUPDATE OR INSERT, returning the key either way via aSUSPEND-ed output parameter. - MergeAll reuses the single-row Merge statement the same way InsertAll does, with the same
batchSizerestriction. - Truncate compiles to a plain
DELETE FROM t— Firebird has noTRUNCATE TABLEstatement (as of 5.0) — which, unlike a real truncate, does not reset aGENERATED ... AS IDENTITYcolumn’s next value. - Every generated statement omits the trailing
;that BaseStatementBuilder normally appends, since Firebird’s DSQL layer rejects a trailing statement terminator on a statement submitted throughFbCommand.CommandText. - Passing a non-null
hintsargument to anyCreate*method throwsNotSupportedException, sinceFirebirdDbSetting.AreTableHintsSupportedisfalse.
Usability
Use StatementBuilderMapper to override it with a custom implementation.
StatementBuilderMapper.Add(typeof(FbConnection), new MyCustomFirebirdStatementBuilder(dbSetting), true);