In AbstractPersistentCollection, there is this method:

        /// <summary> Called by the <tt>Count</tt> property</summary>
        protected virtual bool ReadSize()
        {
            if (!initialized)
            {
                if (cachedSize != -1 && !HasQueuedOperations)
                {
                    return true;
                }
                else
                {
                    ThrowLazyInitializationExceptionIfNotConnected();
                    CollectionEntry entry = 
session.PersistenceContext.GetCollectionEntry(this);
                    ICollectionPersister persister = entry.LoadedPersister;
                    if (persister.IsExtraLazy)
                    {
                        if (HasQueuedOperations)
                        {
                            session.Flush();
                        }
                        cachedSize = persister.GetSize(entry.LoadedKey, 
session);
                        return true;
                    }
                }
            }
            Read();
            return false;
        }

Notice that the call to Read() if the collection is already initialized.  
Read() calls Initialize() which calls InitializeCollection().  Is it just 
me, or does this indeed make no sense?  Why would you initialize a 
collection that is already initialized?  I am asking because this unneeded 
activity by NH is causing an issue in my app.  The scenario arises when I 
try to find out the Count of a collection that was just been read from the 
database.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/SZd5sv22TS0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to