When working with a site that worked like a charm previously, I suddenly get very strange errors when trying to run the GetChildren method of the IContentLoader.
[InvalidOperationException: Lazy loaded property value is not supported by the current property instance]
EPiServer.DataAccess.Internal.LazyPropertyValueLoader.SetValue(PropertyData property, PropertyDataRecord dataRecord, Func`3 valueConverter) +531
EPiServer.DataAccess.Internal.ContentListDB.ReadCustomProperties(DbDataReader reader, Dictionary`2 allFetchedItems, Boolean isReadingVersions) +647
EPiServer.DataAccess.Internal.ContentListDB.ReadPublishedList(DbCommand cmd) +309
EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute(Func`1 method) +78
EPiServer.Core.Internal.DefaultContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader) +246
EPiServer.Core.Internal.DefaultContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector) +455
EPiServer.Core.ContentProvider.GetContentBatch(IList`1 batch, ILanguageSelector selector, List`1& contents, Dictionary`2& contentMap) +128
EPiServer.Core.ContentProvider.GetScatteredContents(IEnumerable`1 contentLinks, ILanguageSelector selector) +917
EPiServer.Core.Internal.ProviderPipelineImplementation.GetItems(ContentProvider provider, IList`1 contentLinks, LoaderOptions loaderOptions) +309
EPiServer.Core.Internal.DefaultContentLoader.GetChildren(ContentReference contentLink, LoaderOptions loaderOptions, Int32 startIndex, Int32 maxRows) +1737
EPiServer.Core.Internal.DefaultContentLoader.GetChildren(ContentReference contentLink, LoaderOptions loaderOptions) +98>
The code that calls GetChildren() looks as follows:
var menuItems = contentLoader.GetChildren(rootLink)
.Select(x => CreateMenuItem(x, currentContentLink, pagePath, contentLoader, filter))
Does anyone have got a clue to why this appears?
The only main difference from the time when it was working is that the database has been moved from the cloud to a local SQLEXPRESS instance.
You get that error when there is some entry in tblContentProperty.LongString ot tblWorkContentProperty.LongString that has a value which length is over the value defined in config by <applicationSettings stringDelayedLoadThreshold="<value here>" /> (the default value for threshold is 255) and where the corresponding PropertyData class does not support delayed loading (does not implement ILazyProperty).
Do you have any custom property with PropertyDataType.LongString that does not implement ILazyProperty?
We ran into this issue when one of the developers on a separate branch checked in code declaring a Property List and set values on certain pages.
As far as I can see in our code base, we dont have any custom properties that builds upon "LongString". However, when I added the setting with a higher value, suddenly the site started working. I guess it may come with a performance penalty to have a high value (?) but as it solved the issue I will mark your answer as the corrent one :)
When looking to the code I see that class PropertyList does not implement ILazyProperty but PropertyList<T> does. So in case you have a property inheriting PropertyList you could consider inheriting PropertyList<T> instead.
We have used the PropertyList as follows:
public class PropertyListBase<T> : PropertyList<T>
private Injected<ObjectSerializerFactory> _objectSerializerFactory;
private IObjectSerializer _objectSerializer;
_objectSerializer = _objectSerializerFactory.Service.GetSerializer("application/json");
protected override T ParseItem(string value)
And we use this class like this:
public class EventDateList : PropertyListBase<EventDate>
It's quite funny that when I read Anikets post, a collegue of mine said "I hade an issue once when someone pushed some changes to a Property List to another branch" .. :D
That should be fine since PropertyList<T> do support lazy loading.
Could it be that it for some reason cant load your custom property and therefore fallback to default type for Json (I see that the default property type that is used when a custom json property cant be loaded does not support lazy loading). If you look in admin mode under 'Config/Edit Custom Property Types' and on the content types that uses the custom property, does any of them indicate that it cant load the custom property type?