SysCache2 not caching entities retrieved via .ContentManager.Query<TPart, TPartRecord>()

Topics: Core, General, Troubleshooting, Writing modules
Dec 28, 2012 at 10:02 PM

From a custom controller action, I am using this query to get a list of ~400 content parts : 

_contentManager.Query<MyPart, MyPartRecord>()
      new QueryHints().ExpandRecords<CommonPartRecord, TitlePartRecord, IdentityPartRecord, AutoroutePartRecord>()
  .OrderBy(myPart => myPart.myPartParent.Name)
  .ThenBy(myPart => myPart.Title)

I'm running the miniprofiler, and it shows that there are 400 queries running every time I load this page. MyPart has a property:  IEnumerable<MyPartConcentrationXrefRecord> MyPartConcentrations {get; set; }

It looks like the 400 queries are Orchard issuing one db query to get the list of MyPartConcentrationXrefRecords for each MyPartRecord. That part I get, but should SysCache's 2nd level caching be caching these? Or is there something additional I can do to nudge Orchard/NHibernate into using the syscache for these collection properties?