Cached entities making round trip to database

141 Views Asked by At

i am caching objects, if i make linq queries on cached entities then... will theses queries make database round trip due to lazy loading in Entity framework?

1

There are 1 best solutions below

0
On BEST ANSWER

If you do not detach the entities before you caching them the entities will keep a reference to the context that created them and use it to lazy load. It is better to detach the entities.

context.Detach(entity);
cachedItems.Add(entity);