November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
You might want to change your property to IEnumerable<T> instead (while keep the internal type to be IList<>)
Just to be sure: are you sure the problem is with that property? Could you try removing it to see what happens?
Yes, the error message confused me a bit, so I did that to be sure. If I remove it, page loads without errors.
If I try to remove JsonConstructor it cannot deserialize the property and instead goes ahead and tries to call productService to populate it.
We solved this rewriting how we added fields to the indexed model - I wrote a blog posts about the topic, read it here: https://www.getadigital.com/blog/enrich-models-upon-indexing/
I have a type WebProduct where I have added a property that I want to add to the indexed object. The property looks like this:
I have also addded the following constructor
The data is indexed properly
When listing products and data comes back from Find, the following exception is thown:
EPiServer.Find.ProjectionException: An exception of type InvalidCastException was thrown while deserializing object. ---> System.InvalidCastException: Unable to cast object of type 'WhereSelectEnumerableIterator`2[System.Globalization.CultureInfo,System.String]' to type 'System.Collections.IList'.
ved Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor`1 creator, String id)
ved Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
ved Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
ved Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
ved EPiServer.Find.ProjectionHelper.DeserializeObject(JToken root)
--- Slutten på sporingen av intern unntaksstakk ---
ved EPiServer.Find.ProjectionHelper.DeserializeObject(JToken root)
ved EPiServer.Find.ProjectionHelper.AddPartialFields(SearchRequestBody requestBody, SearchHit`1 searchHit, Dictionary`2 args)
ved EPiServer.Find.ProjectionHelper.GetFieldValues(SearchRequestBody requestBody, SearchHit`1 searchHit)
ved EPiServer.Find.ProjectionHelper.GetMappedSearchResultItem[TResult](SearchRequestBody requestBody, SearchHit`1 searchHit)
ved EPiServer.Find.ProjectionHelper.GetMappedResult[TResult](SearchRequestBody requestBody, SearchResults`1 jsonResult)
ved EPiServer.Find.MultiSearchExtensions.GetResult[TResult](IMultiSearch`1 multiSearch)
I have tried changing property from IList to List, but that does not affect outcome.
Anyone have any inputs to why this is happening?