Loading...

Last updated: Oct 31 2016

Area: Episerver Find Applies to versions: 12 and higher
Other versions:

Custom object creation

This topic explains how to customize instantiation of objects returned in search results in Episerver Find.

How it works

When objects returned in search results are deserialized, they are instantiated by the JSON.NET serializer. If you require a custom action when instantiating the objects, customize the instantiation with the Client conventions.

Example

An example of configuring custom instantiation can look like this:

//using EPiServer.Find.ClientConvetions;

client.Conventions.ForType<BlogPost>()
    .CreateUsing(() => new BlogPost("someCtorParamValue"));

Note: If indexed objects are so complex that they require custom instantiation, they are often not suitable as search results. It might be better to project the search results to another, simpler class using the Select method.


Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/