orm和ADO.net有什么区别? [英] What is the difference between an orm and ADO.net?

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

问题描述

我正在读一本书,书中写道:如果您将使用ADO.NET创建自己的数据访问层以访问数据库,那么对数据模式是否存在的影响将最小.使用O/RM,您的灵活性将受到所使用工具的限制." ADO.NET和任何其他ORM之间的主要区别是什么?

I am reading a book and it says : "if you will create your own data access layer by using ADO.NET for access into you database, you will be minimally affected whether the data schema exists or not. If however you are using an O/RM, your flexibility will be limited by the tool you use". What is the major difference between ADO.NET and any other ORM?

推荐答案

ADO.NET提供对数据源(如SQL Server)的一致访问 和XML,以及通过OLE DB和ODBC公开的数据源. 数据共享使用者应用程序可以使用ADO.NET连接到这些应用程序. 数据源,并检索,处理和更新它们所使用的数据 包含.

ADO.NET provides consistent access to data sources such as SQL Server and XML, and to data sources exposed through OLE DB and ODBC. Data-sharing consumer applications can use ADO.NET to connect to these data sources and retrieve, handle, and update the data that they contain.

ADO.NET将数据访问与数据处理分离为离散的 可以单独或串联使用的组件. ADO.NET包括 .NET Framework数据提供程序,用于连接到数据库,执行 命令,并检索结果.这些结果要么被处理 直接放置在ADO.NET DataSet对象中以便公开 以临时方式提供给用户,并结合了来自多个 源,或在层之间传递.也可以使用DataSet对象 独立于.NET Framework数据提供者以管理本地数据 到应用程序还是从XML提取.

ADO.NET separates data access from data manipulation into discrete components that can be used separately or in tandem. ADO.NET includes .NET Framework data providers for connecting to a database, executing commands, and retrieving results. Those results are either processed directly, placed in an ADO.NET DataSet object in order to be exposed to the user in an ad hoc manner, combined with data from multiple sources, or passed between tiers. The DataSet object can also be used independently of a .NET Framework data provider to manage data local to the application or sourced from XML.

ADO.NET是允许您连接到DB并使用SQL连接,命令,参数对其进行修改的层. ADO.NET MSDN

ADO.NET is a layer that allows you to connect to DB and modify it using SQL connections, commands, parameters. ADO.NET MSDN

对象关系映射(ORM,O/RM和O/R映射工具)在 计算机科学是一种用于转换数据的编程技术 面向对象编程中的不兼容类型系统之间的转换 语言.实际上,这将创建一个虚拟对象数据库",该数据库 可以从编程语言中使用.都有免费 以及执行对象关系的商业软件包 映射,尽管一些程序员选择构造自己的ORM 工具.

Object-relational mapping (ORM, O/RM, and O/R mapping tool) in computer science is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language. There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to construct their own ORM tools.

Entity FrameworkNHibernate是ORM.这意味着您不必通过SQL连接,命令,参数进行操作-ORM会为您执行操作,并且它允许以OOP方式映射数据库结构:您可以使用C#中的对象在数据库中添加,读取,更新,删除记录.您只需要将对象正确映射到数据库即可. Entity Framework是基于ADO.NET构建的,它在内部使用ADO.NET. SQL语句由ORM生成. ORM

Entity Framework and NHibernate are ORMs. It means that you do not operate by SQL connections, commands, parameters - ORM does it for you and it allows to map your database structure in OOP manner: you can add, read, update, delete records in your DB using objects in C#. You need only map your object to DB correctly. Entity Framework is built on ADO.NET and it uses ADO.NET inside. SQL statements are generated by ORM. ORM

通常,在没有ORM的情况下访问数据库的速度更快,但是您应该提供更多的代码行.如果要以OOP方式操作数据库并编写更具可读性的代码,则应选择ORM.这取决于您选择什么的目的.

Generally, access to DB without ORM is faster, but you should provide more lines of code. If you want to operate your DB in OOP manner and write more readable code you should choose ORM. It depends on your purposes on what to choose.

有些Micro ORM(Dapper,BLToolkit)使您可以编写SQL查询并将参数映射到对象属性.通常,微型ORM的性能要比完整ORM更好,但是ADO.NET仍然更快.

There are Micro ORMs (Dapper, BLToolkit) which allows you to write SQL queries and map parameters to object properties. Micro ORMs, in general, have better performance than Full ORMs, but ADO.NET is still faster.

此外,StackOverflow上还有一些问题和答案: EF与ADO.NET

Also, there are some questions and answers on StackOverflow: EF vs ADO.NET

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

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