withPreparedStatement Method
Deprecated in 4.11. Use IModelDb.createQueryReader or ECDb.createQueryReader to query.
IModelDb.createQueryReader is an asynchronous API. If you encounter a use case that cannot be converted to async, please report an issue at https://github.com/iTwin/itwinjs-core/issues. Mean while use IModelDb.withPreparedStatement for synchronous API calls where conversion to async is not possible.
Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding the oldest statements as it fills. For statements you don't intend to reuse, instead use withStatement.
withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors: booleantrue): T
@returns the value returned by callback
.
@see withStatement
Parameter | Type | Description |
---|---|---|
ecsql | string | |
callback | (stmt: ECSqlStatement) => T | the callback to invoke on the prepared statement |
logErrors | boolean | Determines if error will be logged if statement fail to prepare |
Returns - T
the value returned by callback
.
Defined in
- core/backend/src/IModelDb.ts Line 423
Last Updated: 17 April, 2025