.net - Entity Framework Caching with the Repository Pattern -


if want implement caching when using repository pattern , entity framework, couldn't simple logic outside of entity framework handle caching?

e.g.

if(cache[productskey] != null) {     return converttoproducts(cache[productskey]); } else {     var products = repository.products;     cache[productskey] =  products;     return products; } 

it seems lot of people over-complicating this. or doing way going limiting in way?

i prefer repository clean. prefer implementing caching in service layer if needed.

so 100% agree sample. repository returns products (by running query) , can cache or not in other layers.

p.s.: assume start object context when it's needed(session start) , dispose when session ends.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -