forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (37 loc) · 1.42 KB
/
Copy pathProgram.cs
File metadata and controls
43 lines (37 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using Microsoft.Data.Sqlite;
namespace InteropSample
{
class Program
{
static void Main()
{
using (var connection = new SqliteConnection("Data Source=:memory:"))
{
connection.Open();
// Get the underlying sqlite3 object
var db = connection.Handle;
SQLitePCL.raw.sqlite3_trace(
db,
(_, statement) => Console.WriteLine(statement),
null);
// You could also use db.ptr to access the native sqlite3 struct to, for example,
// invoke a [DllImport] method.
var command = connection.CreateCommand();
command.CommandText = "SELECT $value";
command.Parameters.AddWithValue("$value", "Trace me!");
using (var reader = command.ExecuteReader())
{
// Get the underlying sqlite3_stmt object
var stmt = reader.Handle;
var steps = SQLitePCL.raw.sqlite3_stmt_status(
stmt,
SQLitePCL.raw.SQLITE_STMTSTATUS_VM_STEP,
resetFlg: 0);
Console.WriteLine($"VM operations: {steps}");
// Likewise, use stmt.ptr to access the native sqlite3_stmt struct.
}
}
}
}
}