Link Search Menu Expand Document

SqLiteStatementBuilder


This class is the BaseStatementBuilder-derived implementation for SQLite. It is automatically registered by SqliteBootstrap — you do not need to instantiate it directly under normal use.

It generates [table]-quoted, @-parameterized SQL, and uses LIMIT/OFFSET for BatchQuery and the internal skip/take query.

CreateMerge and CreateMergeAll throw NotImplementedException — SQLite has no MERGE statement, and the INSERT OR REPLACE fallback for it exists in source only as commented-out code. This normally wouldn’t matter, since Merge/MergeAll never reach these methods for SQLite: SqLiteDbSetting sets IsUseUpsert to true, which reroutes both operations through an Exists-then-Insert/Update flow instead. The exception only surfaces if you call CreateMerge/CreateMergeAll directly, or if a custom IDbSetting sets IsUseUpsert back to false for a SqliteConnection.

For Insert, the newly generated identity or primary key value is returned via CAST(last_insert_rowid() AS ...) (identity column) or the supplied parameter (non-identity primary key). InsertAll instead appends a SQLite RETURNING clause (requires SQLite 3.35+) to read back the generated value per batched row.

Truncate is compiled as DELETE FROM [table] ; VACUUM, since SQLite has no native TRUNCATE TABLE statement.

Constructors

public SqLiteStatementBuilder(IDbSetting dbSetting,
    IResolver<Field, IDbSetting, string> convertFieldResolver = null,
    IResolver<Type, Type> averageableClientTypeResolver = null)

convertFieldResolver defaults to SqLiteConvertFieldResolver, used to render CAST(...) expressions for typed fields.

Usability

Use StatementBuilderMapper to override it with a custom implementation.

StatementBuilderMapper.Add(typeof(SqliteConnection), new MyCustomSqLiteStatementBuilder(dbSetting), true);