Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Microsoft.Data.Sqlite
uses SQLitePCLRaw
to interact with the native SQLite library. SQLitePCLRaw
provides a thin .NET API over the native SQLite API. SqliteConnection
and SqliteDataReader
provide access to the underlying SQLitePCLRaw objects letting you call these APIs directly.
The following example shows how to call sqlite3_trace
to write executed SQL statements to the console:
// Get the underlying sqlite3 object
var db = connection.Handle;
sqlite3_trace(
db,
(_, statement) => Console.WriteLine(statement),
null);
And the following example shows calling sqlite3_stmt_status
to see how many SQLite virtual machine steps a SQL statement compiled into:
// Get the underlying sqlite3_stmt object
var stmt = reader.Handle;
var steps = sqlite3_stmt_status(
stmt,
SQLITE_STMTSTATUS_VM_STEP,
resetFlg: 0);
Console.WriteLine($"VM operations: {steps}");
The SQLitePCLRaw objects even expose a pointer to the native objects letting you P/Invoke additional native SQLite APIs.