using SQLite.Net2; namespace GCLocalServerRewrite.common; public static class DatabaseHelper { /// /// Static method to allow local data services to initialise their associated database conveniently. /// /// The SQLite database name /// The SQLite database tables to create (if required) /// An initialised SQLite database connection public static SQLiteConnection InitializeLocalDatabase(string databaseName, params Type[] tables) { if (!Directory.Exists(PathHelper.DataBaseRootPath)) { Directory.CreateDirectory(PathHelper.DataBaseRootPath); } var databasePath = Path.Combine(PathHelper.DataBaseRootPath, databaseName); var database = new SQLiteConnection(databasePath); foreach (var table in tables) { database.CreateTable(table); } return database; } public static SQLiteConnection ConnectDatabase(string databaseName) { var databasePath = Path.Combine(PathHelper.DataBaseRootPath, databaseName); var database = new SQLiteConnection(databasePath); return database; } }