使用 ContentPartRecord 会导致运行时错误
我正在尝试向 Orchard 站点添加一个小部件,并创建了一个继承自 ContentPartRecord 的新内容部分。它构建得很好,但是当我运行 Orchard.exe 或浏览该网站时,我收到此错误:
Exception Details: NHibernate.MappingException: Association references unmapped class: System.string
这是我的课程:
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using System.Collections.Generic;
namespace Hjn.Models
{
public class PropertySearchRecord : ContentPartRecord
{
public virtual List<string> PropertyTypes { get; set; }
public virtual List<string> Locations { get; set; }
public virtual List<double> MinimumPrices { get; set; }
public virtual List<double> MaximumPrices { get; set; }
}
public class PropertySearchPart : ContentPart<PropertySearchRecord>
{
[Required]
public List<string> PropertyTypes
{
get { return Record.PropertyTypes; }
set { Record.PropertyTypes = value; }
}
[Required]
public List<string> Locations
{
get { return Record.Locations; }
set { Record.Locations = value; }
}
[Required]
public List<double> MinimumPrices
{
get { return Record.MinimumPrices; }
set { Record.MinimumPrices = value; }
}
[Required]
public List<double> MaximumPrices
{
get { return Record.MaximumPrices; }
set { Record.MaximumPrices = value; }
}
}
}
我对这个课程很迷茫。 如果您愿意,我也可以发布堆栈跟踪。请告诉我。谢谢!
I am trying to add a widget to an Orchard site and I made a new content part that inherits from ContentPartRecord. It builds just fine but when I go to run Orchard.exe or when I browse to the site I get this error:
Exception Details: NHibernate.MappingException: Association references unmapped class: System.string
Here is my class:
using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using System.Collections.Generic;
namespace Hjn.Models
{
public class PropertySearchRecord : ContentPartRecord
{
public virtual List<string> PropertyTypes { get; set; }
public virtual List<string> Locations { get; set; }
public virtual List<double> MinimumPrices { get; set; }
public virtual List<double> MaximumPrices { get; set; }
}
public class PropertySearchPart : ContentPart<PropertySearchRecord>
{
[Required]
public List<string> PropertyTypes
{
get { return Record.PropertyTypes; }
set { Record.PropertyTypes = value; }
}
[Required]
public List<string> Locations
{
get { return Record.Locations; }
set { Record.Locations = value; }
}
[Required]
public List<double> MinimumPrices
{
get { return Record.MinimumPrices; }
set { Record.MinimumPrices = value; }
}
[Required]
public List<double> MaximumPrices
{
get { return Record.MaximumPrices; }
set { Record.MaximumPrices = value; }
}
}
}
I'm pretty lost with this one.
I can post the stack trace too if you'd like. Just let me know. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,不要使用 List<>您的列的类型。相反,将它们作为 nn 关系进行管理。有一个关于此的文档主题: http://docs.orchardproject .net/Documentation/Creating-1-n-and-nn-关系
Yes, don't use List<> types for your columns. Instead, manage them as n-n relationships. There is a doc topic on that: http://docs.orchardproject.net/Documentation/Creating-1-n-and-n-n-relations