Mapping Exception with simple module

Topics: Troubleshooting, Writing modules
Oct 27, 2011 at 11:00 AM

Hello everybody,

a little note: my english is bad. sorry guys ^^°

i take my first steps with orchard and develope a simple module for create and display seminar. It based on SimpleCommerce

i try to save a seminar, but i get the exception MappingException No persister for: SeminarDetails.Models.Seminar.SeminarPartRecord

i dont find the error or bug in my code. i already reseted my embedded database (SQL Server Compact), but no changes. i hope, you guys can help me.

 

the structure of my module:

public class SeminarPartRecord : ContentPartRecord
    {
        #region Properties

        public virtual int MaxParticipant { get; set; }

        public virtual int ParticipantCount { get; set; }

        public virtual float Price { get; set; }

        #endregion
    }


public class SeminarPart : ContentPart<SeminarPartRecord>
    {
        [Required]
        public int MaxParticipant
        {
            get
            {
                return Record.MaxParticipant;
            }

            set
            {
                Record.MaxParticipant = value;
            }
        }

        [Required]
        public int ParticipantCount
        {
            get
            {
                return Record.ParticipantCount;
            }

            set
            {
                Record.ParticipantCount = value;
            }
        }

        [Required]
        public float Price
        {
            get
            {
                return Record.Price;
            }

            set
            {
                Record.Price = value;
            }
        }
    }

public class SeminarHandler : ContentHandler
    {
        public SeminarHandler(IRepository<SeminarPartRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
        }
    }

public class SeminarDriver : ContentPartDriver<SeminarPart>
    {
        private const string TEMPLATE_NAME = "Parts/Seminar";

        protected override DriverResult Display(SeminarPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape(
                "Parts_Seminar",
                () => shapeHelper.Parts_Seminar(
                    MaxParticipant: part.MaxParticipant,
                    ParticipantCount: part.ParticipantCount,
                    Price: part.Price));
        }

        protected override DriverResult Editor(SeminarPart part, dynamic shapeHelper)
        {
            return ContentShape(
                "Parts_Seminar_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: TEMPLATE_NAME,
                    Model: part,
                    Prefix: Prefix));
        }

        protected override DriverResult Editor(SeminarPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }

public class Migrations : DataMigrationImpl
    {
        public int Create()
        {
            SchemaBuilder.CreateTable(
                "SeminarPartRecord", 
                table => table
                    .ContentPartRecord()
                    .Column("MaxParticipant", DbType.Int32)
                    .Column("ParticipantCount", DbType.Int32)
                    .Column("Price", DbType.Single));

            return 1;
        }

        public int UpdateFrom1()
        {
          ContentDefinitionManager.AlterPartDefinition(
                "SeminarPart",
                builder => builder.Attachable());
          return 2;
        }

        public int UpdateFrom2()
        {
            ContentDefinitionManager.AlterTypeDefinition(
                "Seminar", 
                cfg => cfg
                    .WithPart("CommonPart")
                    .WithPart("RoutePart")
                    .WithPart("SeminarPart")
                    .Creatable()
                    .Indexed());
            return 3;
        }
    }

Coordinator
Oct 27, 2011 at 10:42 PM

This looks fine, so I'd suspect that your handler is not getting picked up for some reason (like an OrchardFeature attribute missing, or mismatching the feature name). You might want to set some breakpoints in there and see whether it gets called at all.