SaaS CMS has officially launched! Learn more now.

Map to Nested List Object in ViewModel


I have a complex JSON object with nested lists and nesteded values. Traditionally in a MVC environment I can use List Model binding which allows me to map to a list nested within the object. Below is an example of how it would be done in traditional MVC within a single Model file.

public class StudentRush : PageData
public virtual ContentArea Form { get; set; }
public virtual ContentArea FormSubmit { get; set; }
public virtual List<ElectronicAddress> ElectronicAddresses { get; set; }

public class ElectronicAddress
public virtual string Address { get; set; }
public virtual object Id{ get; set; }
public virtual bool IsFromAffiliation { get; set; }

When I try this in Episerver I get the error Type...could not be mapped to a PropertyDefinitionType. This is the case even when I use IList. Does anyone know how I can achieve model binding without straying too much away from the traditional method?


Apr 04, 2019 16:11


Using custom complex objects as properties on a page model cant be done by default. Depending on what you want to achieve with the list I would suggest either creating a custom property definition or setting up a selectionfactory.

Apr 04, 2019 16:44

Episerver CMS properties have to be able to load from/save to primitive types (datetime, int, decimal, etc.). In cases of complex types, you need to define a backing type to let the system knows how to save that property to a LongString one, and how to read from it (it does not have to be LongString, of course, but that is the most common backing type). I think the links provided by Gustav are good starting point. 

Apr 04, 2019 16:57

Hi Gabe,

What you want to do should be possible with a PropertyList<T> although using a ContentArea and blocks is typically recommended.

What you're missing is the PropertyDefinitionTypePlugIn, have a look at the documentation:

Edited, Apr 04, 2019 21:25

Hey all,

Thanks for all of the help it's much appreciated.

I realize that I'm working in an Episerver 7 environment and the feature that Jake Jones is referring to is only avaible in Episerver version 9+. I will work with my  team on updating our CMS version then attempt to implement the `PropertList<T>` method.



Apr 09, 2019 22:08
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.