Cache with CacheManager a ContentPart with LazyFields

Topics: Core, General
Feb 16, 2013 at 2:11 PM
I need help! :-(

Is it possible to cache with CacheManager a ContentPart with LazyFields?

I have a ContentPart with a LazyField and when I try to get it from cache it return me this error:
Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.

Source Error: 


Line 563:
Line 564:        public IContentQuery<ContentItem> Query() {
Line 565:            var query = _context.Resolve<IContentQuery>(TypedParameter.From<IContentManager>(this));
Line 566:            return query.ForPart<ContentItem>();
Line 567:        }

Source File: c:\Siel\Orchard\Orchard.Source.1.6\src\Orchard\ContentManagement\DefaultContentManager.cs    Line: 565 
Any Ideas??
Feb 16, 2013 at 3:59 PM
The problem is related to autofac.. I tried to update to autofac 3.0 but the error remain...

Any idea is really appreciated..
Developer
Feb 16, 2013 at 5:24 PM
The error is probably not directly related to your problem.
Anyway, never cache content items in any way as they have DB references open. If you want to cache something, cache POCOs (that you could create by copying data from a content item).
Feb 16, 2013 at 5:37 PM
Sorry, what do you mean with POCOs?

Thank you
Feb 16, 2013 at 6:26 PM
POCO = Plain Old C# Objects

basically, make a class that has properties for the data you want to cache, this will be your POCO. Then cache instances of the POCO(s).