public void TestNestedReaderSQLite() { using (var db = new SQLDBConnection(SQLiteTestConnection)) { db.Open(); try { db.Transaction((t) => { try { t.ExecuteNonQuery("DROP TABLE test"); } catch (Exception) { } }); db.Transaction((t) => { t.ExecuteNonQuery("CREATE TABLE test(i INTEGER)"); t.ExecuteNonQuery("INSERT INTO test VALUES(:V)", DbParam.New("V", 1)); }); } catch (Exception) { } var i = 0; db.ExecuteReader("SELECT * FROM test WHERE i=:V", (rd) => { db.ExecuteReader("SELECT * FROM test", (rd) => { return(true); }); i++; return(true); }, DbParam.New("V", 1)); if (i != 1) { throw new Exception("Data read not successfull"); } }; }
public void TestSelectOutOfTransactionSQLite() { using (var db = new SQLDBConnection(SQLiteTestConnection)) { db.Open(); db.Transaction((th) => { try { th.ExecuteNonQuery("DROP TABLE test"); } catch (Exception) { }; }); db.Transaction((th) => { th.ExecuteNonQuery("CREATE TABLE test(i INTEGER)"); th.ExecuteNonQuery("INSERT INTO test(i) VALUES(1)"); }); db.ExecuteReader("SELECT i FROM test", (rd) => { db.Transaction((th) => { th.ExecuteNonQuery("UPDATE test SET i=2 WHERE i=1"); //db.ExecuteReader("SELECT i FROM test", (rd) => //{ // return true; //}); }); return(true); }); db.Transaction((th) => { th.ExecuteNonQuery("DROP TABLE test"); }); db.Close(); }; }
public void TestDBException() { var s = ""; using (var db = new SQLDBConnection("sqlite", "", "", ":memory:")) { db.Open(); try { var SQL = "SELECT * FROM NotExistedTable"; db.ExecuteReader(SQL, (rd) => { return(true); }); }catch (Exception ex) { s = ex.Message; } db.Close(); }; if (s == "") { throw new Exception("Exception was not generated in ExecuteReader"); } }
public void TestExecuteReader() { using (var db = new SQLDBConnection("sqlite", "", "", ":memory:")) { db.Open(); try { db.Transaction((t) => { t.ExecuteNonQuery("CREATE TABLE test(i INTEGER)"); t.ExecuteNonQuery("INSERT INTO test VALUES(:V)", DbParam.New("V", 1)); }); } catch (Exception) { } var i = 0; db.ExecuteReader(@"SELECT * FROM test WHERE i=:V", (rd) => { i++; return(true); }, DbParam.New("V", 1)); if (i != 1) { throw new Exception("Data read not successfull"); } db.Close(); }; }