private static void _selectAndVerifyManually(TypeWithByteArrayField orig, System.Data.IDbConnection db) { using (var cmd = db.CreateCommand()) { cmd.CommandText = @"select ""content"" from ""type_with_byte_array_field"" where ""id"" = 1 --manual select"; using (var reader = cmd.ExecuteReader()) { reader.Read(); var ba = reader["content"] as byte[]; Assert.AreEqual(orig.Content.Length, ba.Length); Assert.AreEqual(orig.Content, ba); } } }
private static void _insertManually(TypeWithByteArrayField orig, System.Data.IDbConnection db) { using (var cmd = db.CreateCommand()) { cmd.CommandText = @"INSERT INTO ""type_with_byte_array_field"" (""id"",""content"") VALUES (@Id, @Content) --manual parameterized insert"; var p_id = cmd.CreateParameter(); p_id.ParameterName = "@Id"; p_id.Value = orig.Id; cmd.Parameters.Add(p_id); var p_content = cmd.CreateParameter(); p_content.ParameterName = "@Content"; p_content.Value = orig.Content; cmd.Parameters.Add(p_content); cmd.ExecuteNonQuery(); } }