什么是NHibernate的? [英] What is NHibernate?

查看:92
本文介绍了什么是NHibernate的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为后续到我的<一个href=\"http://stackoverflow.com/questions/959161/is-making-a-dll-compatible-to-all-database-is-good-idea\">$p$pvious问题。我是一个ASP.NET程序员,我想知道的NHibernate将如何帮助我让我的工作会比其他方式更快地完成更容易和。 pretend我一无所知NHibernate的。这是什么,什么可以在为我做?

As a followup to my previous question. I am an ASP.NET Programmer, and am wondering how NHibernate would help me get my job done easier and more quickly than it would otherwise. Pretend I know nothing about NHibernate. What is it, and what can it do for me?

推荐答案

NHibernate的是一个ORM,或对象关系映射。在同一行的LINQ to SQL,实体框架,LLBLGEN,和其他人,ORM工具去除大部分的需要编写存储过程来处理你的业务对象共同的数据访问(CRUD)。 ORM工具要求创建(手动或使用一个可视化设计......取决于你选择一个)追踪,你的对象的属性表和/或视图到列映射在你的数据库的映射规范。当您需要检索对象的ORM工具为您生成相应的SQL,并将其发送到数据库。到时候更新你的对象时,ORM不仅将创建SQL插入,更新和删除你......它也将批量这些命令,这样命令的单个连接和批量发送到数据库执行事务中的整个事情。 ORM工具也可以让你在一个单一的去选择整个对象图提高查询的效率,产生最有效的SQL的任务。

NHibernate is an ORM, or Object-Relational Mapper. In the same line as LINQ to SQL, Entity Framework, LLBLGen, and others, ORM tools remove most of the need to write stored procedures to handle common data access (CRUD) for your business objects. ORM tools require that you create (either manually or with a visual designer...depends on the one you choose) a mapping specification that traces which properties of your objects map to which columns of your tables and/or views in your database. When you need to retrieve objects, the ORM tool generates the appropriate SQL for you, and sends it to the database. When the time comes to update your objects, the ORM will not only create the SQL to insert, update, and delete for you...it will also batch those commands so that a single connection and batch of commands are sent to the database and performs the whole thing in a transaction. ORM tools can also improve the efficiency of your queries by allowing you to select entire object graphs in a single go, generating the most efficient SQL for the task.

使用ORM工具,你还需要进行查询,但是你要么与ORM的环境或会话对象的基本方法,或与该ORM自定义查询语言。这些天来,最ORM的,包括NHibernate的,还提供LINQ支持,允许您使用标准的LINQ语法查询对象模型,进而转换为对数据库的SQL查询你。

With ORM tools, you still need to query, however you either with basic methods on the ORM's context or session object, or with a custom query language for that ORM. These days, most ORM's, including NHibernate, also provide LINQ support, allowing you to use standard LINQ syntax to query your object model, which in turn is translated to SQL queries against your database for you.

OR映射器的好处是,你几乎集中的$ C $所有C到您的域名,而不是域和存储的特效之间的分裂它。您减轻您的数据库存储过程负荷,重构你的数据库,如果需要不断出现,提供了更大的业务灵活性,不仅在你的领域,也与你的数据库架构提供较少的一个障碍。既然你不必写SQL,尤其是如果你使用LINQ,你经常可以创建更省力更高效的应用程序以较低的长期维护成本。

The benefit of OR mappers is that you centralize almost ALL of your code into your domain, rather than splitting it between domain and stored procs. You lighten the stored procedure load on your database, providing less of a barrier to refactoring your database if the need ever arises, providing greater business agility not only in your domain, but also with your database schema. Since you don't have to write SQL, and especially if you use LINQ, you can often create a more efficient application in less effort with lower long term maintenance costs.

除了其必然的战争你的DBA的(如果有的话),OR映射器可以给,可以减少实施工作,提高可维护性,并提供更高的业务灵活性表带来可观的收益。

Aside from the inevitable war with your DBA's (if you have them), OR mappers can bring considerable benefits to the table that can reduce implementation effort, improve maintainability, and provide greater business agility.

希望这能回答这个问题。 ;)

Hope that answers the question. ;)

这篇关于什么是NHibernate的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆