locked
complex objects are not loaded into the list RRS feed

  • Question

  • User-1108051076 posted

    Hello asp.net,

    I am caching a list into my program. The list has navigation properties to other complex objects. Complex objects are loaded sometimes, sometimes they are not. I mean some objects are filled in the list properly with depth more than one, sometimes the same list is not loaded with those objects. 

    It happens for example when I build my application and re-run the project.

    I was wondering why?

    Does it have to do with lazy-loading? or it is my db connection management? or it is something else?

    The properties with depth 1, ie simple types, are loaded fine, always.

    Best Regards

    kourosh

    Tuesday, July 18, 2017 7:40 AM

Answers

  • User753101303 posted

    Hi,

    Yes for now it seems a lazy loading issue (ie what is loaded depends on what you actually used when placed in cache).

    Try to explicitely load the related data you want to cache using for example Include: see https://msdn.microsoft.com/en-us/library/jj574232(v=vs.113).aspx

    Mare sure also to not abuse the cache (ie ending up loading a bunch of related data that won't be used often).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 18, 2017 7:50 AM