简体   繁体   中英

What's the relationship between Castle, LinFu and Spring with NHibernate?

I am a newbie to NHibernate and a bit confused about Castle, LinFu and Spring.

I understand that NHibernate helps in DDD and one can map entities to database using xml or Fluent NHibernate. But wondering how Castle, LinFu and Spring are associated to NHibernate.

Can anyone please shed some light or can point to any web link?

Personally I have used Castle and LinFu. I tended to use Castle if I was using other Castle components as well, such as Windsor. In fact Castle have an NHibernate facility as well which can be helpful. I used LinFu when I didn't use any other Castle components.

This blog post is slightly old but has some useful information on it: http://nhforge.org/blogs/nhibernate/archive/2008/11/09/nh2-1-0-bytecode-providers.aspx

Check out the answer to these questions:

What are the differences between LinFu.DynamicProxy and Castle.DynamicProxy?

NHibernate proxy class, what should I choose?

NHibernate 2.1 Proxy Factory options - what are the differences and which to choose?

Castle and the others are used by NH to perform dependency injection and type interception. NH is able to lazy-load data for example, because it creates proxies to your own types and intercepts calls to them. That way it can make DB calls and populate instances in a sort of automagical way.

All three of them do basically the same thing; it's up to you to decide which one you prefer.

Although all seem comparable at first glance, I've personally avoided Linfu due to the following issue with S#arp Arhciture. This one bit me bad enough that I've been forever gun-shy. The Castle provider has never steered me wrong.

As the other answers pointed out, all these providers work.

For what it's worth, the dynamic-update mapping configuration (DynamicUpdate() in FluentNHibernate) seems to work only with Castle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM