D
D
DarkByte20152017-02-09 08:42:42
ORM
DarkByte2015, 2017-02-09 08:42:42

What is the feature of Dapper?

I read this guide on Dapper and I just can’t understand how it differs from the usual ADO.NET? The same classes are also used there, regular SQL queries, no ORM smells ... ORM is when pure SQL does not have to be written at all. Like in Django or Yii.
P.S. Do not agitate me in favor of the Entity Framework. I know about it and would be happy to do it myself, but the customer's requirement is tough Dapper.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eremin, 2017-02-09
@DarkByte2015

First comment on that article:
The difference, perhaps, is that you have automatic mapping (judging by the article).
In ADO.NET, you need to manually fetch values ​​from the reader yourself (like reader.GetInt32(0)). Which is not very nice, especially when working with a large number of complex tables
Toli is the case when you describe a class, make a request and ask to return an instance

User user = null;
using (IDbConnection db = new SqlConnection(connectionString))
   {
         user = db.Query<User>("SELECT * FROM Users WHERE Id = @id", new { id }).FirstOrDefault();
   }

Actually, here is the ORM for you. You don't work with the query result directly. You have the ability to immediately get an instance of the class and work with it.
And the fact that an SQL command is given as input looks, to some extent, even pleasant and convenient.
Here's more about why Dapper (especially the section "Dapper and relational queries" - finally fire) - https://msdn.microsoft.com/en-us/magazine/mt703432.aspx
But about who is faster - https: //www.exceptionnotfound.net/dapper-vs-entity...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question