nhibernate映射字符串列表

时间:2012-07-26 06:20:14

标签: c# fluent-nhibernate-mapping

我有具有以下属性的实体SampleObject

SampleObject.cs
    Guid Id {get; set;}
    string Name {get; set;}
    IList<string> Images {get; set;}

我试图像这些

那样映射这些ImagePathUrls属性
Map(x => x.Images, ("ImagePathUrl")).Length(255);

在数据库方面,我有ImagePathUrlnvarchar 255列的表格。

在调试时我收到以下错误

Could not determine type for: System.Collections.Generic.IList`1
[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089, for columns: NHibernate.Mapping.Column(ImagePathUrl)

1 个答案:

答案 0 :(得分:1)

您正在将List映射到字符串列。

HasMany(x => x.Images).WithKeyColumn("SampleObjectId").WithTableName("SampleObjectImages").AsElemen‌​t("ImagePathUrl");
相关问题