Search code examples
c#postgresqlnpgsql

Passing array of any type to postgres stored procedures using npgsql


Is there a way of passing array of any type from c# code to postgres stored procedure as parameter using npgsql.

Will anyarray or anyelement can be of any use in this scenario.


Solution

  • An "array of any type" (anyarray) is a PostgreSQL pseudo-type that's simply used to write functions which accept any area. It isn't a type which actually exists - you can't have a column of anyarray.

    So to answer your question, you can use Npgsql to send an array of int, of text, or any other datatype to a PostgreSQL function which accepts anyarray. Npgsql has no knowledge about anyarray and doesn't care about it, it's just a PostgreSQL-side detail.