public void TestIssue210() { using (var connection = _connectionStringBuilder.Connection().OpenWithTransaction()) { connection.ExecuteSql("DROP TABLE IF EXISTS foo"); connection.ExecuteSql("DROP FUNCTION IF EXISTS insert_foo(integer, jsonb)"); connection.ExecuteSql("CREATE TABLE foo (id integer, list jsonb)"); connection.ExecuteSql( @"CREATE FUNCTION insert_foo(id integer, list jsonb) RETURNS void AS $body$ INSERT INTO foo VALUES (id, list) $body$ LANGUAGE SQL" ); connection.Execute("insert_foo", new JsonColumn { Id = 1, List = new[] { 1, 2, 3, 4, 5 } }); } }
/// <summary> /// Initializes a new instance of the NpgsqlConnectionWithSchema class. /// </summary> /// <param name="connectionString">The connection string to wrap.</param> /// <param name="schema">The schema to select upon opening the connection.</param> public NpgsqlConnectionWithSchema(NpgsqlConnectionStringBuilder connectionString, string schema) : base(connectionString.Connection()) { if (schema == null) { throw new ArgumentNullException("schema"); } if (!Regex.Match(schema, String.Format(CultureInfo.InvariantCulture, "^{0}(,{0})*$", _validPostgresIdentifier)).Success) { throw new ArgumentException("Schema contained invalid characters", "schema"); } Schema = schema; _switchSchemaSql = String.Format(CultureInfo.InvariantCulture, "SET SCHEMA '{0}'", Schema); }
/// <summary> /// Initializes a new instance of the NpgsqlConnectionWithRecordsets class. /// </summary> /// <param name="connectionString">The connectionstring to use to connect to the database.</param> public NpgsqlConnectionWithRecordsets(NpgsqlConnectionStringBuilder connectionString) : base(connectionString.Connection()) { }