使用 ContentPartRecord 会导致运行时错误

发布于 2024-12-23 12:35:38 字数 1538 浏览 3 评论 0原文

我正在尝试向 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

_蜘蛛 2024-12-30 12:35:38

是的,不要使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文