Adding an NHibernate collection to your QuickWatch in Visual Studio loads the entire collection even if it is marked with lazy loading.

I spent most of the day trying to improve performance on an application. We use NHibernate 2.0 and try to lazy load most of the collections inĀ  memory (RAM).
I found these two links very useful for troubleshooting my performance issue:
and the NHibernate reference:

The curious thing is I got really confused when testing my
NHibernateUtil.IsInitialized(_myobject.MyCollection) line and it was false
but I saw a query retrieving the collection in SQL Profiler…

until I realized that adding the collection to the Watch windows in Visual Studio initializes the collection. The same happens if you open the collection in QuickWatch. :-p

The tools used for troubleshooting performance were Ant Profiler and SQL Server Profiler.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.