Load Content Item + Lazy Load it's part

Topics: Customizing Orchard, Troubleshooting, Writing modules
Aug 29, 2014 at 10:23 AM
Edited Aug 29, 2014 at 10:24 AM
Dear all,

I'm running into a problem located at lazy loading parts.

I've a content Item which includes 4 different parts. One of these parts, includes lazy loaded content.
    public class CupStructurePart : ContentPart<CupStructurePartRecord>
    {
        private readonly LazyField<IEnumerable<CupRoundRecord>> _cupRounds = new LazyField<IEnumerable<CupRoundRecord>>();
        private readonly LazyField<IEnumerable<CupPairingRecord>> _cupPairings = new LazyField<IEnumerable<CupPairingRecord>>();
I also added some "onLoading" events within the parts handler.
            OnLoading<CupStructurePart>((context, part) => part.CupRoundsField.Loader(delegate { return cupStructureService.Value.GetCupRounds(part.CupRecord, part.MaxCount); }));
            OnLoading<CupStructurePart>((context, part) => part.CupPairingsField.Loader(delegate { return cupStructureService.Value.GetCupPairings(part.CupRecord); }));
I'm now trying to load the whole content item via the content manager:
return ContentManager.Get(cupId);
That's the situation so far. I thought, that as soon as the content manager starts loading the content item, all relating parts get loaded as well, resulting in my "onLoading" events to get hit and therefore the lazy loaded content will be set.

Now I'm encountering the problem that these events are not getting hit and therefore the lazy loaded fields are not filled.

Where is my mistake? :)

Thanks for your help!
Aug 29, 2014 at 2:07 PM
nvm :)