什么是NHibernate的,我为什么要使用它?我为、用它、要使、NHibernate

2023-09-03 10:24:18 作者:浮生若只是夢

可能重复:   什么是NHibernate的?

我听说过这个名字的 NHibernate的的用了很多,但我不真正理解它是什么。我已经阅读维基百科的文章,但我不明白怎么在我的C#应用​​程序使用NHibernate (桌面W / WPF,网络瓦特/ ASP.NET MVC)将:

I've heard the name NHibernate used a lot, but I don't really understand what it is. I've read the Wikipedia article, but I don't understand how using NHibernate in my C# applications (desktop w/ WPF, web w/ ASP.NET MVC) will:

更改code 更容易/更快

我应该看看在我的项目使用NHibernate?

更新:感谢您​​确定这是一个傻瓜!我并没有意识到,这已经问。

UPDATE: Thanks for identifying this as a dupe! I didn't realize that this had already been asked.

我想我真正的问题是关于NHibernate的对LINQ到SQL(我一直在使用中我所有的应用场合),但已被要求的这里和here.

I guess my real question is about NHibernate versus Linq to SQL (which I've been using in all of my applications), but that has already been asked here and here.

谢谢大家! :)

推荐答案

NHibernate的是一个ORM(对象关系映射器)。其目的是在映射的持久性数据库的面向对象的应用程序对象的表。

NHibernate is an ORM (Object Relational Mapper). Its purpose is to map objects in your OO application to tables in a database for persistence.

为什么你需要它?因为它可以节省你写了很多繁琐的ADO.NET code。本质上,它开发CRUD应用程序时提高开发人员的生产力,也就是应用程序的主要目的是为了创建,读取,更新和删除数据库中的数据。

Why would you need it? Because it can save you from writing a lot of tedious ADO.NET code. Essentially it enhances developer productivity when developing CRUD applications, that is, applications whose main purpose is to Create, Read, Update, and Delete data in a database.

NHibernate的是开源的,你需要知道你正在你的应用程序依赖于第三方库,其长期目标可能会偏离你的。

NHibernate is open source, and you need to realise that you are making your application dependent on third party libraries, whose long term goals may diverge from yours.

如果你想要一个ORM的生产力,而不会引入这种依赖关系,考虑实体框架,或LINQ2SQL(注意LINQ2SQL锁定你到SQL Server)。

If you want the productivity of an ORM without introducing this dependency, consider Entity Framework, or Linq2SQL (noting that Linq2SQL locks you into SQL Server).

最后,如果你不需要一个ORM的提高生产力,并且要绝对控制,坚持普通的老ADO.NET。

And finally if you don't need the productivity enhancement of an ORM, and you want absolute control, stick to plain old ADO.NET.

 
精彩推荐