private static void CreateTestTable(SQLiteConnection connection) { connection.Open(); connection.ExecuteNonQuery(@" CREATE TABLE TestTable ( BooleanColumn BIT, ByteColumn TINYINT, DateTimeColumn DATETIME, DecimalColumn DECIMAL, FloatColumn SINGLE, GuidColumn UNIQUEIDENTIFIER, Int16Column SMALLINT, Int32Column INT )"); connection.ExecuteNonQuery(@" INSERT INTO TestTable VALUES ( 1, 1, '2014-04-01 14:45:00', '3.14', 3.14, x'1cb113dcfbe69f44a8925e2a47b05350', 1, 1 )"); }
public void GetValues_when_null_scalar_column() { using (var connection = new SQLiteConnection("Filename=:memory:")) { connection.Open(); connection.ExecuteNonQuery(@"CREATE TABLE TestTable (Int32Column INT)"); connection.ExecuteNonQuery(@"INSERT INTO TestTable VALUES (NULL)"); using (var command = connection.CreateCommand()) { command.CommandText = "SELECT * FROM TestTable"; using (var reader = command.ExecuteReader()) { reader.Read(); var values = new object[1]; var count = reader.GetValues(values); Assert.Equal(1, count); Assert.Equal(DBNull.Value, values[0]); } } } }
public override void Commit() { CheckCompleted(); _connection.ExecuteNonQuery("COMMIT"); _connection.Transaction = null; _connection = null; }
private void CreateTestTable(SQLiteConnection connection) { connection.ExecuteNonQuery(@" CREATE TABLE TestTable ( StringColumn TEXT )"); }
private static void CreateTestTable(SQLiteConnection connection) { connection.Open(); connection.ExecuteNonQuery(@" CREATE TABLE TestTable ( TestColumn INTEGER )"); }
public void IsolationLevel_is_infered_when_unspecified() { using (var connection = new SQLiteConnection("Filename=:memory:")) { connection.Open(); connection.ExecuteNonQuery("PRAGMA read_uncommitted = 1"); using (var transaction = connection.BeginTransaction()) { Assert.Equal(IsolationLevel.ReadUncommitted, transaction.IsolationLevel); } } }
internal SQLiteTransaction(SQLiteConnection connection, IsolationLevel isolationLevel) { Debug.Assert(connection != null, "connection is null."); Debug.Assert(connection.State == ConnectionState.Open, "connection.State is not Open."); _connection = connection; _isolationLevel = isolationLevel; if (_isolationLevel == IsolationLevel.ReadUncommitted) { _connection.ExecuteNonQuery("PRAGMA read_uncommitted = 1"); } else if (_isolationLevel == IsolationLevel.Serializable) { _connection.ExecuteNonQuery("PRAGMA read_uncommitted = 0"); } else if (_isolationLevel != IsolationLevel.Unspecified) { throw new ArgumentException(Strings.FormatInvalidIsolationLevel(isolationLevel)); } _connection.ExecuteNonQuery("BEGIN"); }