Dapper is a micro ORM which make database operation simple using Models. It has capability to handle all type of databases.

The real charm of dapper is when you are working ModelView pattern., l leave that topic for another post.

How to use latest dapper ORM version with .Net project ?

Dapper require .Net Framework 4.7.2 or latter. Make sure the visual studio project support the Dapper or you can change the target Frame Work.

Open the Nuget manager and browse dapper and install the dapper and associated contrib extension.

Usage

We can use dapper by importing the Dapper library as follows

using Dapper; .... var sql ="select * from emp order by id"; using (SqlConnection con = <sql connection>)  {    con.QueryFirst<Models.Employee>(sql);                            }

The above example is based on C#.Net. This will return a list of Employee objects, which will be very useful for binding to a datagridview or a Combo control.


This free site is ad-supported. Learn more