You will need to supply a JsonConverter for CustomerSku to get this to work since this is CatalogContent I assume. I would also suggest not trying to do this either as it was not inteded to store list of contentdata. If you want a list of Content use the following instead, with allowed types.
[CLSCompliant(false)] [AllowedTypes(typeof(CustomerSku))] [Display(Order = 10)] public virtual IList<ContentReference> Items { get; set; }
Sorry misread the post and was confused by MetaDataType. Seems you may have another class called CustomerSku that is intefering. Can you try overrriding these methods in your PropertyList.
public override PropertyData ParseToObject(string value) { var prop = new PropertyCustomerSkuList(); prop.ParseToSelf(value); return prop; } protected override CustomerSku ParseItem(string value) { return Parse(value); } /// <summary> public override string ToString() { if (IsNull) { return String.Empty; } return string.Join(StringRepresentationSeparator.ToString(), List.Select(x => x.ToString)); //this needs to handle representing the object as a string }
@Daniel: Thanks, but yeah I did and it didn't help :-/
@Mark: Great, thanks - I'll try that out and report back!
Hi Mark
I tried changing my CustomerSkuListProperty to be like this:
public class CustomerSkuListProperty : PropertyListBase<CustomerSku> { public override PropertyData ParseToObject(string value) { var prop = new CustomerSkuListProperty(); prop.ParseToSelf(value); return prop; } protected override CustomerSku ParseItem(string value) { return base.ParseItem(value); } public override string ToString() { if (IsNull) { return string.Empty; } return string.Join(StringRepresentationSeparator.ToString(), List.Select(x => x.ToString())); //this needs to handle representing the object as a string } }
But still the same exception:
The type System.Collections.Generic.IList`1[[Navico.B2B.Buybook.Web.Models.Catalog.CustomerSku, Navico.B2B.Buybook.Web, Version=1.0.6.41827, Culture=neutral, PublicKeyToken=null]] can not be mapped to a MetaDataType
:-/
Matt
Do you have two CustomerSkus because the error looks like it is a Catalog content type it is trying to use. Are you sure it using your poco object. Also what are you trying to achieve. Maybe IList<ContentReference> is better
Hi Mark
I only have one CustomerSku class in the solution and it's definitely a plain POCO - and only has string getter/setter properties (like in my first post).
Don't think ContentReferences are what I want since the intent is to have a simple list of sku strings for the variation content.
I'm just going to use a commerce MetaStringDictionary (MetaField) instead - I had seen the PropertyList and expected it to be a better way to go, but since I can't figure this out I'll skip using it for now.
Thanks for all your help and advice though!
Matt
I think you need to add a BackingType of string since the catalog content provider does not know how to use the PropertyList
Thanks Mark, yeah perhaps that's what I've missed here - If the content provider is different I guess that might be why. Appreciate your input!
Hey Guys,
I know this is an old post, but I got the same error when I try to use IList property into the commerce catalog (e.g. ProductNode).
So for the solution, I have added the BackingType attribute on the property and pass the xxxxProperty into typeof(xxxxProperty).
Step 1: Create a Model
public class ThreeColumnModel
{
public virtual string Title { get; set; }
public virtual string Summary { get; set; }
}
Step 2: Register Model as property
[PropertyDefinitionTypePlugIn()]
public class ThreeColumnModelProperty : PropertyList<ThreeColumnModel>
{
}
Step 3: Add the BackingType attribute and used EditorDescriptor for registering the collection type model.
[BackingType(typeof(ThreeColumnModelProperty))]
EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<ThreeColumnModel>))]
public virtual IList<ThreeColumnModel> ThreeColumns{ get; set; }
Thanks,
I'm on EPiServer CMS 9.6.1 and have been following Per Magne Skuseth's blog post "Trying out PropertyList". I can see plenty of others commenting on that post who have gotten much further so it must be possible.. But for me when I have the property like this:
I keep getting the NotSupportedException with "The property data type IList can not be mapped to a MetaDataType".
And I've tried putting [BackingType(typeof(CustomerSkuListProperty))] and I then get NotSupportedException "The property data type Json can not be mapped to a MetaDataType".
I have definitely included the:
And have copied the PropertyListBase exactly as in his post so cannot figure why I get those exceptions..
Oh and the CustomerSku class is pretty simple like this:
Anything I might have missed?