PgSql.Param does not support <int?[]> but NpgsqlParameter does

I am able to use Nullable Command Parameters using NpgsqlParameter, but not with PgSql.
E.g.

    command.Parameters.Add(new NpgsqlParameter<int[]>("i",ids.ToArray()));
    command.Parameters.Add(new NpgsqlParameter<string[]>("n", names.ToArray()));
    command.Parameters.Add(new NpgsqlParameter<int?[]>("k", idNullables.ToArray()));

but when I use

var id_param = PgSql.Param<int[]>("i", ids.ToArray());
var name_param = PgSql.Param<string[]>("n", names.ToArray());
var idnullable_param = PgSql.Param<int?[]>("k", idNullables.ToArray()); //this line fails

with error : ‘Type ‘Nullable`1’ not found in ‘TypesMap’’

I am using it to do unnest in postgres. Should PgSql not support nullable array lists?

The PgSql methods like Param are just small wrappers. It looks like by default the TypesMap doesn’t include int?[] which is why you are seeing that error. You can add it yourself if needed using PostgreSqlDialect.Instance.TypesMap.Add, that way your calls to PgSql.Param will resolve int?[].

This is now supported in latest v6.8.1 which is now available on MyGet.

1 Like