Skip to content

Instantly share code, notes, and snippets.

@Ciantic
Created February 11, 2022 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ciantic/c8c7ddd7a5a0b2468c50564a6073c92b to your computer and use it in GitHub Desktop.
Save Ciantic/c8c7ddd7a5a0b2468c50564a6073c92b to your computer and use it in GitHub Desktop.
This is test code I threw away, it looks like SQLite3 update hook is *per* connection, making it useless for subscribing for events between processes (even if they use same database).
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using SQLitePCL;
static public class Thing {
public static void ListenSqlite(DbContext context)
{
context.Database.OpenConnection();
var c = context.Database.GetDbConnection() as SqliteConnection;
SQLitePCL.raw.sqlite3_update_hook(c.Handle, test_func, new object());
}
static readonly delegate_update test_func = (db, wint, char1, char2, sqlitei64) =>
{
Console.WriteLine("Yeah?");
};
}
<!-- Omitted other stuff, just deps -->
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.0" />
<PackageReference Include="SQLitePCLRaw.core" Version="2.0.7" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment