2012-10-02 80 views
0

我在我的数据库的单个列中有一个数组。 Postgres里,它看起来是这样的:在NHibernate中映射数组

orientation double precision[] 

其中 '方向' 是列名。 如何用C#映射它?

< property name="Orientation"/>在我的hbm.xml文件中没有做这项工作。 我在C#类包含字段:

public virtual double[] Orientation { get; set; } 

这给了我一个例外:

无法在现场Orientat9_0_铸铅字双[]将 类型SerializableType的价值。请检查以确保映射为 正确,并且您的DataProvider支持此数据类型。

并且还这样:

无法转换类型的对象 'System.Double []' 键入 'System.Byte []'。

我不想在我的数据库中创建任何额外的表。

+0

看这个:http://stackoverflow.com/questions/1746414/how-configure-nhibernate-to-map-to-an-array-if-there-is-no-index-in-the-table –

回答

0

您将需要编写自己的IUserType来处理此问题。

+0

我尝试过,但未能如愿。你能为此提供一些代码吗?这是我缩小到(注意我的数组总是包含6个元素): http://pastebay.net/1149297 – jacek11