Using ContentPartRecord causes runtime error

Topics: Core, Customizing Orchard, General, Writing modules
Dec 29, 2011 at 10:22 PM

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!

Dec 30, 2011 at 1:12 PM

The problem is you have List<String> and List<double> - NHibernate has no way to map that to a database field. It only understands plain strings, doubles, etc.