views:

124

answers:

1

I've just finished converting a large amount of legacy code to use NHibernate. The next thing I want to do is introduce an IOC container for hooking up the data access layer repositories and other such things. There are a variety of options out there at the moment - Castle Windsor, StructureMap, NInject, Unity etc; the choice is difficult.

Should I let the fact that NHibernate is already using Castle Windsor influence my decision?

I can imagine some potential benefits - for example lower memory usage. But there may be downsides, such as having to stick with the version of Castle that NHibernate is compiled against, rather than being able to upgrade the IOC container when I choose.

Thoughts?

+2  A: 

NHibernate doesn't use any IOC container. It uses the Castle.DyanmicProxy project for creating proxy objects to facilitate lazy-loading (although this can be replaced with LinFu or your own proxy factory if you like).

You can use whichever IOC container you think most suited to you, your team and your requirements.

One point in favour of Castle Windsor is that there is already an NHibernate facility which takes care of session and transaction management for you.

John Rayner