Link Search Menu Expand Document

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) and FIRST m SKIP n (for BatchQuery/skip-take queries), written directly after SELECT — Firebird has no TOP/LIMIT keyword.
  • Insert excludes the identity column from the column list (letting GENERATED ALWAYS/BY DEFAULT AS IDENTITY auto-populate it) and appends a RETURNING <key> AS "Result" clause, which Firebird’s RETURNING on INSERT natively 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 (batchSize of 1); a batchSize greater than 1 throws NotSupportedException, since FirebirdDbSetting.IsMultiStatementExecutable is false.
  • Merge compiles to Firebird’s native UPDATE OR INSERT INTO ... MATCHING (...) RETURNING ... upsert statement — the closest single-statement shape to MySQL’s ON DUPLICATE KEY UPDATE/PostgreSQL’s ON CONFLICT DO UPDATE. When the identity column is itself a qualifier, UPDATE OR INSERT’s MATCHING cannot reliably match a not-yet-inserted row, so the builder instead emits an EXECUTE BLOCK (Firebird’s inline PL/SQL construct) that branches: INSERT when the identity parameter is NULL/0, otherwise UPDATE OR INSERT, returning the key either way via a SUSPEND-ed output parameter.
  • MergeAll reuses the single-row Merge statement the same way InsertAll does, with the same batchSize restriction.
  • Truncate compiles to a plain DELETE FROM t — Firebird has no TRUNCATE TABLE statement (as of 5.0) — which, unlike a real truncate, does not reset a GENERATED ... AS IDENTITY column’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 through FbCommand.CommandText.
  • Passing a non-null hints argument to any Create* method throws NotSupportedException, since FirebirdDbSetting.AreTableHintsSupported is false.

Usability

Use StatementBuilderMapper to override it with a custom implementation.

StatementBuilderMapper.Add(typeof(FbConnection), new MyCustomFirebirdStatementBuilder(dbSetting), true);