Category

Dapper

Insert data in database through Dapper ORM

By | Dapper, ORM | No Comments

You can insert tha data in database through Dapper ORM. Just use Execute Method, but before this you
have to importĀ Dapper namespace.

To use Dapper name space first you have to add reference of dapper from nuget if you are using visual studio.

to add reference of dapper in visual studio ->Tools->Nuget Package Manager->Package Manager Console

and than type below line in console to add dapper reference in visual studio.

Install-Package Dapper -Version 1.50.5

you can check versions of Dapper on Nuget site.

https://www.nuget.org/packages/Dapper/


using Dapper;

string sql = "INSERT INTO testTable (name,password) VALUES(@name,@password)";
var affectedrows = con.Execute(sql, new { name = "Demo", password = "123456" });
if (affectedrows > 0)
{
    return "Done";
}