I try to keep NHibernate out of my domain objects so that I can make
testing easier, but I'm changing my tune when it comes to other areas
of my applications.  I used to over-engineer data access by wrapping
everything up in "repositories" (which weren't really repositories)
and trying to keep all NH code out of everything except the NH
assembly that we created.

What I came to realize, and what was really highlighted in a post by
Ayende, is that it makes doing anything non-trivial extra difficult.
So you either have a ton of code to work around the fact that you
don't want your MVC app, for example, knowing NH exists or you just
don't use features that are available.  What really pushed me towards
just biting the bullet and using NH directly in our MVC app is the
futures feature in NH.

Before, I'd call all these different get() methods on our various
"repositories" and I couldn't make use of futures or any other NH
feature because our data access was so abstracted.  Now, I just get
the data I need when I need it directly though NHibernate because most
of our controller actions need a specific set of data that never lent
themselves well to the methods available in our "repositories."

But like everything else, this is actively evolving...

On Apr 26, 10:17 am, Matan Goldschmiedt <[email protected]> wrote:
> I have asked myself, and I replayed "why don't you ask the nice people
> of the nhusers group what they think?"
> :)
>
> Can anyone state what are the pros and cons of referencing NH in your
> domain?
>
> On Apr 25, 11:53 pm, Gunnar Liljas <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
> > You must ask yourself, is it really a problem that NHibernate is referenced?
> > It may be, but in most cases it's not, and trying to work around it is just
> > hours of work sacrificed on the altar of dogmatism.
>
> > /G
>
> > 2011/4/25 Matan Goldschmiedt <[email protected]>
>
> > > Hi,
>
> > > I'd like to use NHibernate.Search via Nuget, I thought I'd start by
> > > attributing my entities using the NHibernate.Search.Attributes
> > > namespace. Problem is that the NH Search package depends on NH which
> > > means that my domain class library would reference NHibernate.
>
> > > Up until now I managed to avoid that since I figured that my domain
> > > shouldn't be aware of NHibernate at all, is it a lost fight, or am I
> > > better adding a manual reference only to NHibernate Spatial?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "nhusers" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Make sure to check out my blog atwww.codecovered.net

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

Reply via email to