在ngpsql中使用string [] [] [英] Use string[][] with ngpsql

查看:79
本文介绍了在ngpsql中使用string [] []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不支持?尝试将命令参数设置为的数据插入时出现异常:

Its not supported? I get an exception when trying to insert data with command parameter set as:

var parameter = ((IDbDataParameter)cmd.Parameters[index]);
var list = (string[][])value;
parameter.Value = list;

有消息


System.NotSupportedException:Npgsql或PostgreSQL不支持此.NET类型:System.String [] []

System.NotSupportedException: This .NET type is not supported in Npgsql or your PostgreSQL: System.String[][]

我正在使用PostgreSQL 9.4,并创建了一个类型为 text [] [] 的列。由于 text [] 映射到 string [] 没有任何问题,所以我看不到二维数组的原因

I'm using PostgreSQL 9.4 and created a column with type text[][]. Since text[] maps to string[] without any issues, I can't see a reason why two dimensional arrays are not working.

推荐答案

没有数据类型 text [] [] 。可以允许使用多种语法格式来表示多个数组维,但是在内部,所有这些都被映射为适用于任意维数的相同(且唯一)数组类型: text [] 。在您的.net声明中尝试 string []

There is no data type text[][] in Postgres. Syntax variants indicating multiple array dimensions are tolerated for documentation, but internally all of those are mapped to the same (and only) array type that works for any number of dimensions: text[]. Try string[] in your .net declaration.

您不必相信我的话,测试一下自己:

You don't have to take my word, test yourself:

SELECT pg_typeof(NULL::text[][])            AS type1
     , pg_typeof('{a,b}'::text[][])         AS type2
     , pg_typeof('{{{a,b},{c,d}}, {{a,b},{c,d}}}'::text[][][][][]) AS type3;


 type1  | type2  | type3
--------+--------+--------
 text[] | text[] | text[]

相关:

  • mapping postgresql text[][] type and Java type

这篇关于在ngpsql中使用string [] []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆