Exemple #1
0
 /// <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 SQLiteMonoDatabase(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.Delete,
                UseUTF16Encoding = true
            };

            sqLiteConnection = new SqliteConnection(connectionStringBuilder.ConnectionString);
            sqLiteConnection.Open();
            sharedConnection = new SharedConnection(sqLiteConnection);
            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.Delete,
                UseUTF16Encoding = true
            };

            sqLiteConnection = new SqliteConnection(connectionStringBuilder.ConnectionString);
            sqLiteConnection.Open();
            sharedConnection = new SharedConnection(sqLiteConnection);
            sqlRunner        = new AdHocSqlRunner(() => sqLiteConnection.CreateCommand(), null, () => true);
        }