Example #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();
                }
            }
        }
Example #2
0
 public void Dispose()
 {
     if (_sqlCon != null)
     {
         _sqlCon.Dispose();
         _sqlConForDelete.Dispose();
         _sqlCon = null;
     }
 }
        public void Dispose_can_be_called_more_than_once()
        {
            var connection = new SqliteConnection("Data Source=:memory:");
            connection.Open();

            connection.Dispose();
            connection.Dispose();
        }
        public void Dispose_closes_connection()
        {
            var connection = new SqliteConnection("Data Source=:memory:");
            connection.Open();

            connection.Dispose();

            Assert.Equal(ConnectionState.Closed, connection.State);
        }