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?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
ADO.NET is a layer that allows you to connect to DB and modify it using SQL connections, commands, parameters. ADO.NET MSDN
Entity Framework
andNHibernate
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. ORMGenerally, 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.
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.
Also, there are some questions and answers on StackOverflow: EF vs ADO.NET
DataSets
andDataReaders
ADO.NET.
Object-Relational Mapper
which is to map an object with a relational world. As the name suggests itbuilds a relation / maps objects (model) to database objects(tables).
ADO.NET
was the traditional way to connect your application to a database & gave the developer entire control over the database operations whereasORM
is built on top ofADO.NET
and usesADO.NET
implicitly.ORM.
ORM
not everything is in your hands since all of the queries are generated by theORM
itself. Now we don't know whether those queries are optimized or not.Micro ORM's
like Dapper, BLToolkit. These provide the esssence of what developers want - an easy way to map Database operations to strongly typed classes.raw speed.
Words of Wisdom:
Dapper
just does mapping but you need to code a lot ,EF
does much more on the top of it and not just mapping. So EF will be slow.ADO.NET
is faster thanDapper
,OLEDB
is faster thanADO.NET
andODBC
can be faster thanOLEDB.
ORM.