Hi guys, for a very complex search we've been indexing some custom .NET objects which we need to search on and to reload back as .NET objects. The searching works fine using the following guide https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/Customizing-serialization/Including-fields/ but we are having problems re-loading the data. As an example I've thrown a simple example up on Alloy for replication.
Firstly on the ArticlePage type I have added the following extra properties/methods. The GetSomeField() should just be returning the standard Name field back.
[Ignore]
public string FindTestField { get; set; }
public string GetSomeField()
{
return Name;
}
public void SetSomeField(string value)
{
FindTestField = value;
}
We then have an initilization module with the following simple code
[ModuleDependency(typeof(IndexingModule))]
public class FindInitialization : IInitializableModule
{
/// <inheritdoc />
public void Initialize(InitializationEngine context)
{
SearchClient.Instance.Conventions
.ForInstancesOf<ArticlePage>()
.IncludeField(x => x.GetSomeField(),(x, value) => x.SetSomeField(value));
}
/// <inheritdoc />
public void Uninitialize(InitializationEngine context)
{
}
}
Episerver Find is indexing this GetSomeField as expected with the correct data, however when doing a search with the following code
var eventPages = SearchClient.Instance.Search<ArticlePage>().GetContentResult();
var firstaPage = eventPages.Items.First();
var findFullname = firstaPage.FindTestField;
The findFullname variable is null? This is a simple example of what we're trying to do, in our real solution this is an IEnumerable of .NET objects but how to we re-serialize the objects back somewhere in the model. I've been looking at the code for the IncludeFieldCustom and Episerver own indexing of objects and can't figure it out.