What query caching ( SetCacheable(true) ) does is store the IDs retrieved by the query; it then hydrates the objects one by one (hopefully, from the entity cache).
What query caching (SetCacheable(true)) does is store the IDs retrieved by the query; it then hydrates the objects one by one (hopefully, from the entity cache). IIRC, when caching a query, FetchModes for related entites are not used, so the Author references are not being initialized. It's worth noting that you shouldn't be using your entities outside a session, but here's a workaround: news = session.
CreateCriteria(typeof(NewsItem)) . SetCacheable(true) . SetFetchMode("Author", FetchMode.
Eager) .List(); foreach (var item in news) { var name = item.Author. Name; } This will force initialization of the proxies inside the sessions; that way you'll be able to use them afterwards. Of course, you need to make sure both NewsItem and Author are cached, otherwise you'll actually decrease the performance by caching the query.
Thanks for the reply Diego - Re not using entities outside a session - I use a Unit of Work to connect to the repository and hydrate the objects. The unit of work completes and returns the entities via a viewModel. I don't want to access the entities outside the session and am trying to populate the viewModel inside the unit of work with the data it needs.
I assumed it would have been the eager loaded associated entities too, but seems that is not the case. Seems I have to force the loading inside the unit of work. – Chev Aug 24 '10 at 12:37.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.