London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Episerver Find - Unable to deserialize IList<string>

Vote:
 

I am indexing pages which have a base class with an IList<string> property like below:

public virtual IList<string> TagCodes

{

   get { return new List<string> { "Shoulder", "Knee", "Video" }; }

}

 

It gets indexed correctly and looks as following when I do index view:

"TagCodes": [
    "Shoulder",
    "Knee",
    "Video"
  ],

However, when I perform the actual search I am getting the following exception "To deserialize objects the $type property must be set.". I am a bit at loss at what is happening and what I am missing.

_searchClient
.Search<ExpertBaseResourcePageType>()
.Select(p => new SearchResultItem
{
TagCodes = p.TagCodes
} as ISearchResultItem)
.GetResult();

Below is exception stack trace as well:

   at EPiServer.Find.ProjectionHelper.DeserializeObject(JToken root)
   at EPiServer.Find.ProjectionHelper.AddPartialFields(SearchRequestBody requestBody, SearchHit`1 searchHit, Dictionary`2 args)
   at EPiServer.Find.ProjectionHelper.GetFieldValues(SearchRequestBody requestBody, SearchHit`1 searchHit)
   at EPiServer.Find.ProjectionHelper.GetMappedSearchResultItem[TResult](SearchRequestBody requestBody, SearchHit`1 searchHit)
   at EPiServer.Find.ProjectionHelper.GetMappedResult[TResult](SearchRequestBody requestBody, SearchResults`1 jsonResult)
   at EPiServer.Find.SearchExtensions.GetProjectedResult[TResult](ISearch`1 search, SearchContext context)
   at EPiServer.Find.SearchExtensions.GetResult[TResult](ISearch`1 search)
#75753
Oct 04, 2013 17:00
Vote:
 

Hi,


What happens if you change the type from an interface to a concrete implementation of list?


IList<string>  ---> List<string>

#75758
Oct 04, 2013 19:55
Vote:
 

This has helped, thank you very much Johan!

#75780
Oct 07, 2013 7:42
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.