I have a nhibernate lazy loaded collection, well a bunch of them in a tree of parent-child relations. When i save some nodes, i have to loop over the active nodes and add a bit of data to them. Trouble is when i access the parents/children it initilises the collections. This is bad as it then loads the whole tree into memory on the saved.
I thought there must be a way to check whether a collection had been loaded lazyily. First i thought about checking the type to see if it was the dynamic proxy. But then ran into this gem at the nhibernate reference guide:

I could just pass the collection to this method, and it would check if it had been initialised. Just waht i was after. The only other place i found a reference to this function then was at the forums:

So why dao function ended up as, because i dont want the nhibernate logic permeating my service layer:

        public bool HasBeenInitialised(ICollection collection) {
            return NHibernateUtil.IsInitialized(collection);


List Forever said...

Fastest Cars In The World We can measure automotive excellence in several ways, but top speed which a automobile can achieve is the one everyone secretly cares about the most

Photo Background Editor said...

"This photo is perfect except for background which is...". Well, let's say "bad". Have you ever thought like that? Probably, you even made an attempt or two to edit the picture with the ruined Photo Background Editor, to no avail. Surely, not all of us are designers or at least IT savvy. So, here is a way for the rest of humanity to change the back scene of any photograph – the Photo Scissors online tool.

Nearbest10 said...

Nearbest10 is a participant in the Amazon Services LLC Associates Program which is an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. Amazon, the Amazon logo, AmazonSupply, and the AmazonSupply logo are trademarks of Amazon.com, Inc. or its affiliate.