/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/standard/data/sqlite/InteropSample/Program.cs
49 строк
2 KB
Andy De George
Move snippets from samples repo to this repo (#17296)
03 мар 2020, 19:23
Не верифицирован
03 мар 2020, 19:23
dbbeda1
Код
Авторство
О чём код?
using System; using Microsoft.Data.Sqlite; using static SQLitePCL.raw; namespace InteropSample { class Program { static void Main() { using (var connection = new SqliteConnection("Data Source=:memory:")) { connection.Open(); #region snippet_Trace // Get the underlying sqlite3 object var db = connection.Handle; sqlite3_trace( db, (_, statement) => Console.WriteLine(statement), null); #endregion // 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()) { #region snippet_StatementStatus // 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}"); #endregion // Likewise, use stmt.ptr to access the native sqlite3_stmt struct. } } } } }