Esempio n. 1
0
 /// <summary>
 /// Creates the database schema from scratch, for initial spinup.
 /// </summary>
 /// <param name="connectionString">The connection string to use.</param>
 /// <param name="additionalSqlStatements">(Optional) Extra SQL to run, e.g. additional tables to create.</param>
 public void CreateSchema(string connectionString, params string[] additionalSqlStatements)
 {
     using (var cnn = new SqliteConnection(connectionString))
     {
         // We need some tiny mods to allow SQLite support
         foreach (var sql in TableCreationScripts.Union(additionalSqlStatements))
         {
             cnn.Execute(sql);
         }
     }
 }
 /// <summary>
 /// Used for testing purposes - destroys and recreates the SQLITE file with needed tables.
 /// </summary>
 /// <param name="extraTablesToCreate">The Extra Tables To Create.</param>
 public SqliteMiniProfilerStorage RecreateDatabase(params string[] extraTablesToCreate)
 {
     using (var cnn = GetConnection())
     {
         // We need some tiny mods to allow SQLite support
         foreach (var sql in TableCreationScripts.Union(extraTablesToCreate))
         {
             cnn.Execute(sql);
         }
     }
     return(this);
 }
        /// <summary>
        /// Used for testing purposes - destroys and recreates the SQLITE file with needed tables.
        /// </summary>
        /// <param name="extraTablesToCreate">The Extra Tables To Create.</param>
        public void RecreateDatabase(params string[] extraTablesToCreate)
        {
            var path = ConnectionString.Replace("Data Source = ", string.Empty); // hacky

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (var cnn = new System.Data.SQLite.SQLiteConnection(MvcApplication.ConnectionString))
            {
                cnn.Open();

                // we need some tiny mods to allow sqlite support
                foreach (var sql in TableCreationScripts.Union(extraTablesToCreate))
                {
                    cnn.Execute(sql);
                }
            }
        }