I am trying to create a simple setting in Orchard that appears in the settings page. I have created a module which is adding my ContentPart to the settings page and is correctly creating a table in the database but every time the cshtml file is rendered and the property of the record is accessed I keep getting the following NHibernate Record.
No persister for: TekFlow.Contact.TekFlowEmailSettingsPartRecord. (TekFlow.Contact is the Module name)
Below is all of the code that I am using to create the Record/Part/Handler/Driver needed in Orchard.
public class TekFlowEmailSettingsPartDriver : ContentPartDriver<TekFlowEmailSettingsPart>
{
public TekFlowEmailSettingsPartDriver()
{
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
protected override DriverResult Editor(TekFlowEmailSettingsPart part, dynamic shapeHelper)
{
return ContentShape("Parts_TekFlowEmailSettings_Edit",
() => shapeHelper.EditorTemplate(TemplateName: "Parts.TekFlowEmailSettings", Model: part, Prefix: Prefix)
);
}
protected override DriverResult Editor(TekFlowEmailSettingsPart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper)
{
bool success = updater.TryUpdateModel(part, Prefix, null, null);
return Editor(part, shapeHelper);
}
}
[UsedImplicitly]
public class TekFlowEmailSettingsPartHandler : ContentHandler
{
public TekFlowEmailSettingsPartHandler(IRepository<TekFlowEmailSettingsPartRecord> repository)
{
Filters.Add(new ActivatingFilter<TekFlowEmailSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository));
}
}
public class TekFlowEmailSettingsPartRecord : ContentPartRecord {
public virtual string SendToEmail { get; set; }
}
public class TekFlowEmailSettingsPart : ContentPart<TekFlowEmailSettingsPartRecord>
{
public string SendToEmail
{
get { return Record.SendToEmail; }
set { Record.SendToEmail = value; }
}
}
public class TekFlowEmailSettingsDataMigration : DataMigrationImpl
{
public int Create()
{
SchemaBuilder.CreateTable("TekFlowEmailSettingsPartRecord",
table => table
.ContentPartRecord()
.Column<string>("SendToEmail", c => c.WithDefault("[email protected]").WithLength(255))
);
ContentDefinitionManager.AlterPartDefinition(
typeof(TekFlowEmailSettingsPart).Name, cfg => cfg.Attachable());
return 1;
}
}