What the title says. I find lazy-loading useless for my needs. I would 
prefer property/collection to return null (or even throw an exception) when 
the code didn't explicitly eager-fetched that data.

The reason is twofold. First I want to prevent all N+1 issues as early as 
possible. Without lazy-loading I would probably got a Null-Reference 
(instead of lazy loading kicking in and leading to N+1 issues) and I would 
immediatly fix my query to properly prefetch data. Now I have to use a 
profiler to see if I have N+1 issues.

Secondly, I have issues in some scenarios with DTOs/Models and products 
like Automapper. When Automaper goes though all properties/collections it 
will trigger lazy-loading even if I don't need that data. Why I would have 
a collection in my DTO/Model that I don't need? Because I like to reuse my 
DTOs/Models for several Views and I include properties/collections that are 
used in some Views but not in others.

I tried to build a solution by making my own custom 
NHibernateProxyFactoryFactory that would return null instead of a Proxy, 
but I didn't have any luck so far.

All ideas?


-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to