Using nested tables v9.0.3.1

EDB Postgres Advanced Server supports nested table collection types created with CREATE TYPE ... AS TABLE OF statements. The EDB .NET Connector supports output parameters declared as nested tables out of the box, whether free-standing types or declared inside packages.

Nested table types mapping

Nested table types are mapped to List<object>s in C#, as it is preferred over ArrayList. These lists contain as many elements as the nested table type's rows. The nested table items are translated to be compatible with the C# application using the following rules:

  • The connector resolves all nested table rows into a List<object> in C# while maintaining and converting each column's underlying type. For example, a [text1, text2, num1] row will be resolved as a [string, string, decimal] item in the list.

  • If the nested type IS TABLE OF a domain type (int, varchar, decimal, etc.), all the rows will be their C# counterpart according to the Supported Types and their Mappings.

  • If the nested type IS TABLE OF a record or composite type not mapped to a C# class, all rows become a nested List containing as many elements as the record or composite fields, with proper type translation.

  • If the nested type IS TABLE OF a record or composite type mapped to a C# class (for example, MyComposite), all rows will be MyComposite instances.

Example: Retrieving nested table output parameter

This program:

  • Creates a package with a nested emp_tbl_typ table type of emp_rec_typ. This package has a stored procedure that fills the nested table output parameter.

  • Maps the nested table type to a C# class via MapComposite<>.

  • Executes and displays the results.

  • Cleans up the database by dropping the package (and implicitly the nested table type)

Note

Always provide type names in lowercase.

Program example

Create an empty console program and paste the following code.

The output should look like this:

Package created
Employee 7499: ALLEN
Employee 7521: WARD
Employee 7566: JONES
Employee 7654: MARTIN
Employee 7698: BLAKE
Employee 7782: CLARK
Employee 7839: KING
Employee 7844: TURNER
Employee 7876: ADAMS
Employee 7900: JAMES
Package successfully deleted