I am trying to serialize my in memory Sqlite db, so I can convert it back into a file later on. I see how you would serialize the db in node.js How does `db.serialize` work in `node-sqlite3` and in C Serialize a database in C. I just have not been able to find a way to accomplish this in C#. If anyone has any insight it would be appreciated!
What I have so far
using System.Data.SQLite;
using Newtonsoft.Json;
using System.Text;
public byte[] SerializeDB(string sql)
{
using(var con = new SQLiteConnection($"Data Source=:memory:;Version=3;New=True;")) {
con.Open();
using(SQLiteCommand cmd = new SQLiteCommand(sql, con)) {
cmd.ExecuteNonQuery();
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(**WHAT SHOULD GO HERE**));
}
}
}