admin管理员组

文章数量:1336643

I have a integer[] slots in my PostgreSQL table and would like to use unnest to fill it in bulk.

 cmd.CommandText = "INSERT INTO inventory (slots) " +
                "SELECT t.slots " +
                      "FROM UNNEST(@slots) AS t(slots) " +
                      "RETURNING inventory_id";

cmd.Parameters.AddWithValue("@slots", new int[10][]);0

When I try this approach (just to test 10 entries with empty array of ints), I'm getting the following error:

Error: The CRL array type System.Int32[][] isn't supported by Npgsql or your PostgreSQL. If you wish to map it to an PostgreSQL composite type array you need to register it before usage.

Is there a simple solution to it?

I tried to add "NpgsqlDbType.Array | NpgsqlDbType.Integer", but to no avail.

本文标签: cUnnest Npgsql bulk query for integer array elementStack Overflow