AutoMapper would like to EagerLoad a single object

33 views
Skip to first unread message

Mark Perry

unread,
Feb 26, 2009, 12:24:36 PM2/26/09
to Fluent NHibernate
Hi

I am using the automapper and would like to keep the default lazy load
on for all but one of the objects where I would like to Eager load for
the entire object graph. Is there a way to do this using the auto
mapper, or am I going to need to map this object separately using a
standard Fluent Map and combine the auto map and and the single Fluent
Map?

If there is a way to get around this using a criteria API I could also
take that approach but I have a deep object graph and I don't really
want to hard code all the association strings into my criteria query.

Thanks, Mark

Mark Perry

unread,
Feb 27, 2009, 4:19:37 AM2/27/09
to Fluent NHibernate
Solved.

.ForTypesThatDeriveFrom<TheTypeIWantToEagerLoad>(map =>
{
map.Not.LazyLoad();
})

Mark

Mark Perry

unread,
Feb 27, 2009, 4:42:56 AM2/27/09
to Fluent NHibernate
.ForTypesThatDeriveFrom<UnitType>(map =>
{
map.SetHibernateMappingAttribute("default-lazy", "false");
})

The previous code will put the lazy="false" on the class mapping but
the
default-lazy="true" on the root element takes priority.

Mark
Reply all
Reply to author
Forward
0 new messages