用于字符串[]在实体NHibernate的是什么地图? [英] What nhibernate mapping is used for string[] in an entity?

查看:91
本文介绍了用于字符串[]在实体NHibernate的是什么地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的现象,我需要坚持:

 公共类Person 
{
公字符串[] {昵称得到;组; }
}



什么映射和表结构将是最好坚持这个字符串数组<? / p>

解决方案

您可以直接映射数组,但是你需要一些额外的列:

 <! - 可以住W / O排序依据 - > 
<数组名=昵称表=昵称的order-by =IndexColumn注解ASC>
<键列=keyColumn/>
<索引列=IndexColumn注解/> <! - 在阵列的位置 - >
<元素列=昵称类型=字符串/>
< /阵列>

如果你没有你需要的其他列,我可能会坚持它作为一个正常的包或列表并将其公开为来自在实体数组。


I have a strange situation I need to persist:

public class Person
{
  public string[] Nicknames { get; set; }
}

What mapping and table structure would be best to persist this string array?

解决方案

You can map arrays directly, but you'll need a few additional columns:

<!-- can live w/o orderby -->
<array name="Nicknames" table="Nicknames" order-by="indexColumn ASC"> 
  <key column="keyColumn"/>
  <index column="indexColumn"/> <!-- position in array -->
  <element column="nickname" type="String"/>
</array>

If you don't have the other columns you need, I would probably persist it as a normal bag or list and expose it as an array from that in the entity.

这篇关于用于字符串[]在实体NHibernate的是什么地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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