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:
http://www.hibernate.org/hib_docs/nhibernate/html/performance.html
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:
http://forums.hibernate.org/viewtopic.php?p=2282177&sid=b5989f2c3f2387add4188a6e13802019
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);
}
No comments:
Post a Comment