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

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.

Inserting Rows using Model

We can use dapper by importing the Dapper library as follows in module.

using Dapper;  

To insert we have to prepare the Model and use IDbConnection to invoke the insert command. Again we have two choice a single row or list of row using a list objects.

 using (SqlConnection con = connection._GetConnection())                      {                          long rec = con.Insert(Salary);                                                    con.Close();                                             }

Here _GetConnection() is a function that return a IDbConnection object and Salary is a regular C# class with table columns and getters and setters.

//Salary  class Salary{ public int id {get;set;} public double slary {get;set;} } 

This free site is ad-supported. Learn more