November Happy Hour will be moved to Thursday December 5th.

GetChildren() - Lazy loaded property value is not supported by the current property instance

Vote:
 

Hi!

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. 

Partial Stacktrace:

[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.Internal.<>c__DisplayClass31_0`1.b__0() +70
   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)
   .FilterForDisplay(requirePageTemplate, requireVisibleInMenu)
   .Select(x => CreateMenuItem(x, currentContentLink, pagePath, contentLoader, filter))
   .ToList();

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.

Best regards

William Hemmingsson

#196167
Aug 21, 2018 10:30
Vote:
 

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?

#196180
Aug 21, 2018 13:51
Vote:
 

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. 

Aniket

#196181
Aug 21, 2018 14:34
Drew Null - Jan 03, 2020 16:45
To expand upon this comment... here is how to trigger this issue in more detail:
1. Start with two developers, each are working with a shared database at the same time.
2. Developer A creates a property list on Page Type X, creates an instance of it, and stages some content.
3. Developer B tries to load that instance of Page Type X with IContentLoader.GetChildren().
4. Developer B gets the error.
Vote:
 

Hi Johan!

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 :)

#196182
Aug 21, 2018 14:36
Vote:
 

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.

#196183
Aug 21, 2018 14:38
Vote:
 

We have used the PropertyList as follows:

public class PropertyListBase<T> : PropertyList<T>
    {
        private Injected<ObjectSerializerFactory> _objectSerializerFactory;
        private IObjectSerializer _objectSerializer;

        public PropertyListBase()
        {
            _objectSerializer = _objectSerializerFactory.Service.GetSerializer("application/json");
        }

        protected override T ParseItem(string value)
        {
            return _objectSerializer.Deserialize<T>(value);
        }
    }

And we use this class like this:

[PropertyDefinitionTypePlugIn]
    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

#196184
Edited, Aug 21, 2018 14:42
Vote:
 

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?

#196185
Aug 21, 2018 14:59
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.