我有一个属性域类的IList<字符串>
,我想要映射到一个表,一个单一的数据值(即它有一个ID,一个外国密钥ID域实体表,并varchar数据列)。
I have a domain class with a property IList<string>
that I want to map to a table with a single data value (i.e. it has an ID, a foreign key ID to the domain entity table, and a varchar data column).
我不断收到错误:协会引用未映射类:System.String
。
我如何能表映射到字符串的集合?
How can I map a table to a collection of strings?
我只是碰到了类似的情况;而且我发现它确实有可能映射字符串的集合。 请注意,您必须对这些字符串作为映射值对象。
I just ran into a similar situation; and I found that it is indeed possible to map a collection of strings. Note that you'll have to map those strings as value objects.
这是我有:
public class Chapter
{
private ISet<string> _synonyms = new HashedSet<string>();
public ReadOnlyCollection<string> Synonyms
{
get { return new List<string>(_synonyms).AsReadOnly(); }
}
}
映射:
<class name="Chapter" table="Chapter">
<set name="Synonyms" table="ChapterSynonyms">
<key column="ChapterId" />
<element column="ChapterCode" type="string" />
</set>
</class>