Reputation: 381
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?
Upvotes: 0
Views: 124
Reputation: 32437
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);
Upvotes: 1