/// <summary> /// Creates an upgrader for SQLite databases. /// </summary> /// <param name="supported">Fluent helper type.</param> /// <param name="sharedConnection">SQLite database connection which you control when it is closed</param> /// <returns> /// A builder for a database upgrader designed for SQLite databases. /// </returns> public static UpgradeEngineBuilder SQLiteDatabase(this SupportedDatabases supported, SharedConnection sharedConnection) { var builder = new UpgradeEngineBuilder(); builder.Configure(c => c.ConnectionManager = new SQLiteConnectionManager(sharedConnection)); builder.Configure(c => c.Journal = new SQLiteTableJournal(() => c.ConnectionManager, () => c.Log, "SchemaVersions")); builder.Configure(c => c.ScriptExecutor = new SqlScriptExecutor(() => c.ConnectionManager, () => c.Log, null, () => c.VariablesEnabled, c.ScriptPreprocessors)); builder.WithPreprocessor(new SQLitePreprocessor()); return builder; }
/// <summary> /// Initializes a new instance of the <see cref="TemporarySQLiteDatabase"/> class. /// </summary> /// <param name="name">The name.</param> public TemporarySQLiteDatabase(string name) { dataSourcePath = Path.Combine(Environment.CurrentDirectory, name); var connectionStringBuilder = new SQLiteConnectionStringBuilder { DataSource = name, Version = 3, DefaultTimeout = 5, JournalMode = SQLiteJournalModeEnum.Memory, UseUTF16Encoding = true }; sqLiteConnection = new SQLiteConnection(connectionStringBuilder.ConnectionString); sharedConnection = new SharedConnection(sqLiteConnection.OpenAndReturn()); sqlRunner = new AdHocSqlRunner(() => sqLiteConnection.CreateCommand(), null, () => true); }
/// <summary> /// Initializes a new instance of the <see cref="TemporarySQLiteDatabase"/> class. /// </summary> /// <param name="name">The name.</param> public TemporarySQLiteDatabase(string name) { dataSourcePath = Path.Combine(Environment.CurrentDirectory, name); var connectionStringBuilder = new SQLiteConnectionStringBuilder { DataSource = name, Version = 3, DefaultTimeout = 5, JournalMode = SQLiteJournalModeEnum.Memory, UseUTF16Encoding = true }; sqLiteConnection = new SQLiteConnection(connectionStringBuilder.ConnectionString); sharedConnection = new SharedConnection(sqLiteConnection.OpenAndReturn()); sqlRunner = new AdHocSqlRunner(() => sqLiteConnection.CreateCommand(), null, () => true); }
/// <summary> /// Initializes a new instance of the <see cref="TemporarySQLiteDatabase"/> class. /// </summary> /// <param name="name">The name.</param> public TemporarySQLiteDatabase(string name) { dataSourcePath = Path.Combine(Directory.GetCurrentDirectory(), name); var connectionStringBuilder = new SQLiteConnectionStringBuilder { DataSource = name, #if !NETCORE Version = 3, DefaultTimeout = 5, #if MONO JournalMode = SQLiteJournalModeEnum.Off, #else JournalMode = SQLiteJournalModeEnum.Memory, #endif UseUTF16Encoding = true #endif }; sqLiteConnection = new SQLiteConnection(connectionStringBuilder.ConnectionString); sqLiteConnection.Open(); sharedConnection = new SharedConnection(sqLiteConnection); sqlRunner = new AdHocSqlRunner(() => sqLiteConnection.CreateCommand(), new SQLiteObjectParser(), null, () => true); }