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?

4

2 回答 2

2

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.

于 2009-11-05T00:11:56.230 回答
0

不要将 Castle IOC 与 Nhibernate 一起使用。SessionFactory的Sessions和IOC实现本身存在多线程问题。由于这个隐藏的架构问题,我们使一个大型项目失败。使用 Spring IOC 或其他 IOC。城堡很轻,很简单,但没用。

于 2013-01-22T15:06:08.803 回答