Let's say we have an entity named "Blog" that has many "Post"s in it:
[ActiveRecord("Blogs")]public class Blog : ActiveRecordValidationBase<Blog>{ private IList _posts; // ... snipped ... [HasMany(typeof (Post), Table = "Posts", Lazy = true, ColumnKey = "BlogId")] public IList Posts { get { return _posts; } set { _posts = value; } } // ... snipped ... }
Configure your web application to support lazy loading:
Now, How do you know if lazy loading is (really)enabled:
Blog b = Blog.Find(1);bool isInit = NHibernateUtil.IsInitialized(b.Posts);
If isInit shows true, then lazy loading wasn't enabled and you need to make sure you didn't miss anything. if it shows false - lazy loading is on!
Thanks for Ayende Rahien for pointing on NHibernateUtill, this can be quite handy.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Oren Ellenbogen
<= Contact me via E-mail
newtelligence dasBlog 2.2.8279.16125