Eager fetch support for ICriteria

70 views
Skip to first unread message

Stuart Carnie

unread,
Sep 15, 2011, 7:58:35 PM9/15/11
to nhibernate-...@googlegroups.com
Hi all,

I've created a feature request for adding eager fetching of lazy loaded properties to ICriteria.  I suspect it's a trigger on the loader, so it shouldn't be too hard.  My recommendation would be to add a new method, FetchAllProperties to ICriteria.  

Thoughts and feedback welcomed.

Stuart Carnie

unread,
Sep 19, 2011, 8:17:49 PM9/19/11
to nhibernate-...@googlegroups.com
I've been working on this feature, and decided to follow an approach more consistent with the SetFetchMode API.

ICriteria has two new methods, 
  • SetLazyPropertyFetchMode(LazyPropertyFetchMode mode)
    • Sets the fetch mode for the current ICriteria instance
  • SetLazyPropertyFetchMode(string associationPath, LazyPropertyFetchMode mode)
    • Sets the fetch mode for the specified association path
The LazyPropertyFetchMode enum is defined as follows:

public enum LazyPropertyFetchMode
{
/// <summary>
/// The default fetch mode, which is lazy
/// </summary>
Default,

/// <summary>
/// Eager fetch lazy properties
/// </summary>
Select,
}

I have a working implementation with various unit tests.  I will explore my implementation a bit further and then push my branch up for review.

Cheers,

Stuart
Reply all
Reply to author
Forward
0 new messages