Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Support of IList<T> in EPiServer Content Delivery API v3 + CMS 12

Vote:
 

Hello, 

I am trying to create the custom property in the page type and fetch that property with the rest of the page's property via Content Delivery API.

This post is exactly what I need  https://world.optimizely.com/blogs/K-Khan-/Dates/2018/7/use-of-ilist-in-episerver-content-delivery-api/  but that is for the API v1.

Basically what I need is that this page custom property :

[Display(
    GroupName = SystemTabNames.Content,
    Name = "Panel List",
    Order = 30)]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<TitleBody>))]
public virtual IList<TitleBody> Panels { get; set; }

serialize into the API response.

Does anybode have any advise how to do that?

I tried with IPropertyConverterProvider but the documentation is non existant and I miss a few parts there.

Thanks.

#270344
Jan 21, 2022 18:02
Vote:
 

did you override the Resolve method of IPropertyConvertorProvider - if you post your code i can help to see what is missing,

#270506
Jan 24, 2022 23:50
Vote:
 

I have my Property Converter :

public class TitleBodyPropertyConverter : IPropertyConverter
{
   public IPropertyModel Convert(PropertyData propertyData, ConverterContext contentMappingContext)
   {
      throw new NotImplementedException();
   }
}

which I am not completely sure how to map my property to the content api property and because of that I can't implement the Resolve method. For now the Resolve method is empty:

public class TitleBodyPropertyConverterProvider : IPropertyConverterProvider
{
    public IPropertyConverter Resolve(PropertyData propertyData)
    {
        //if (propertyData == yourPropertyModel)
        //{
        //    return yourPropertyConverter;
        //}

        return null;
    }

    public int SortOrder { get; }
}

#270510
Jan 25, 2022 10:47
Vote:
 

You seems to have taken the right approach 

Have you created the PropertyModel to be return from IPropertyConverter

YourPropertyModel : PropertyModel<IList<T>, PropertyList<T> ?

and then in  Resolve you can check if propertyData is of type PropertyList<T>

It should work.

#270582
Jan 26, 2022 10:23
Vote:
 

Thank you @Muhanned for your response. 

With the latest version of the Content Delivery API it's enough to have your custom property model YourPropertyModel : PropertyModel<IList<T>, PropertyList<T>  and it works.  No need for the IPropertyConverter to be implemented. At least in my case.

I had a corrupted DB and that's why nonthing works what ever I tried.

#270767
Jan 28, 2022 13:40
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.