views:

29

answers:

2

Hi,

does Entity Framework have a caching mechanism like DataSet/DataTables have?

In other words if you start using EF is it really just a way to easily get data in/out of the database without providing an additional caching layer like DataSet/DataTables did where you have an in-memory representation (on-line/off-line) and which at some point you could say to "persist all changes to database"

+1  A: 

You can check out this caching provider for entity framework. It contains 3 implementations of ICache interface which can be used in your applications:

  • AspNetCache – cache which uses ASP.NET caching mechanism.
  • InMemoryCache – simple, in-memory cache with basic LRU expiration policy.
  • VelocityCache – implementation of caching which uses Microsoft Distributed Cache codename "Velocity" CTP3.
CodeToGlory
+1  A: 

Depends on how complex a cache you are referring to.

EF has an Object Cache. See...

Identity Resolution, State Management, and Change Tracking

The ObjectContext represents a container for in-memory objects. The object context, with the help of other classes and interfaces, manages an object's identity, state, original and current values of the object's properties, and tracks the changes made to each object in the cache.

and...

Saving Changes and Managing Concurrency

These articles introduce the EF Object Cache somewhat.

For further caching, you can write a wrapper as in... http://blogs.msdn.com/efdesign/archive/2008/07/09/transparent-caching-support-in-the-entity-framework.aspx

kervin