Created
February 11, 2022 22:36
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?"); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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