Exemplo n.º 1
0
        static BaseDataSQLite()
        {
            #if DEBUG
            _sqliteFile = Paths.DebugSQLitePath;
            #else
            _sqliteFile = Paths.ReleaseSQLitePath;
            #endif

            //_connectionString = String.Format("Data Source=:memory:");
            //_connectionString = String.Format("Data Source={0};Version=3;Pooling=True;Max Pool Size=100;Synchronous=Normal;Journal Mode=WAL", _sqliteFile);
            _connectionString = String.Format("Data Source={0}", _sqliteFile);

            if (!File.Exists(_sqliteFile))
            {
                if (!File.Exists(Paths.SqlPath))
                    throw new FileNotFoundException("Cannot find SQL file: " + Paths.SqlPath);
                else {
                    // Generate database
                    var conn = new SqliteConnection(_connectionString);
                    conn.Open();
                    var sql = File.ReadAllText(Paths.SqlPath);
                    conn.Execute(sql);
                    conn.Dispose();
                }
            }
        }