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!
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!
By default GetResult validates if you query for something implementing IContentData. This is done to avoid confusion as the queried result from GetContent isn't a true copy of the IContentData in the DB (The serialized object in the index is simply not a full copy of the object. GetContentResult solves this by actually fetching the true object from the db before returning the result). However if you like to override this you can turn off the default TypeValidationConvention by resetting the convention:
client.Conventions.TypeValidationConventions = new TypeValidationConventions();
/Henrik
Is this possible to do using the IContentIndexer in a IInitializableModule? Since this error basically occurs in all our queries. And does turning off the default TypeValidationConvention have any side effects?
/Peter
You can do this in an IInitializableModule. It has no side effects, it only disables type validation when using GetResult.
Can you please provide a code example? I'm not getting it right.
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
[InitializableModule]
public class FindConfigModule : IInitializableModule
{
private readonly IContentIndexer client = ContentIndexer.Instance;
public void Initialize(InitializationEngine context)
{
client.Conventions.TypeValidationConventions = new TypeValidationConventions();
}
public void Uninitialize(InitializationEngine context)
{
}
public void Preload(string[] parameters)
{
}
}
I used the following code(the conventions of the EPiServer.Find.IClient type):
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))] [InitializableModule] public class FindConfigModule : IInitializableModule { private readonly Injected<EPiServer.Find.IClient> client; public void Initialize(InitializationEngine context) { client.Service.Conventions.TypeValidationConventions = new TypeValidationConventions(); } public void Uninitialize(InitializationEngine context) { } }
Hello,
After upgrading to the latest version of EPiServer Find we get the error "Please use GetContentResult extension method for getting results with content types". The thing is, the type/types we are searching for are not content types. What changed in the new version?
/Peter