score:2

Accepted answer

both linqtosql and entityframework provide both features (deferred loading and data caching).

for example, if you initially load a customer, that customer will be cached and if you ask for it again you'll get the same instance.

if you don't load a customer's orders during that initial load, then the orders property of that customer instance will be in an unloaded state. when you do load those orders, then the order instances will be available through that property.

  • linqtosql will load the property the first time it is used.
  • entityframework will load the property when it is asked to do so (using the load method).

in both technologies, the context is the thing that does the caching... so if you use more than one context instance - you could observe different customer instances that really represent the same customer.


addressing your questions in comments. i'll be talking linqtosql, but this stuff should work in entityframework as well.

if i shut off deferred loading i take it the data caching will still work?

yes, that will work. however, they are not totally independent.

is data cache flushing dependent on whether there are changes in datatable and or time?

there is no flushing or resetting the cache. if you want a fresh cache, the thing to do is to create a new datacontext. each instance of datacontext has its own cache.

  • there is a way to pull update the cache with changes in the database aka - refresh.
  • there is no way to push changes from the database to the cache.

Related Query