Dapper ORM A NuGet library that will extend your IDbConnection interface
with awesome extensions!

string sql = "SELECT * FROM Invoices"; using (var conn = My.ConnectionFactory()) { var invoices = conn.Query<Invoice>(sql); }

Dapper FAQ



Is Dapper an ORM?

Yes and no! People are still arguing about it. Dapper has earned the title of king of the C# Micro ORM but is considered by multiple people as a simple object mapper for .NET.



Is Dapper better than Entity Framework?

Yes and no! People will prefer Dapper when they want to write the SQL query themselves with optimal performance.



Is Dapper SQL Injections safe?

Yes, it's 100% safe if you use parametrized queries as you should always do!



Do Dapper support Bulk Insert?

No, but a third-party library does: Dapper Plus. It's a prime library that extend Dapper with all bulk operations.

Learn More


Do Dapper support my database provider?

Probably yes since Dapper provides extensions to the IDbConnection interface. It's your job to write the SQL compatible with your database provider.



Do Dapper support Transaction?

Yes, Dapper support transaction and every method that can use one have an optional parameter to specify it.

Trusted by thousands around the world!

More than 2000 satisfied customers spreaded across over 75 countries


We had a particularly large (500,000 entities) EF save operations that was taking 12 minutes, this is now down to 30 seconds.

Stewart Menday, Australia, New South Wales

That's really cool! I didn't actually expect you to build a new release in just a day, to be honest, but this is really awesome

Kimwan Ogot, USA, Minneapolis

I would absolutely recommend your product. It is simple, cheap, effective.

Dapper Features

Dapper - Execute

Execute a command one or multiple times and return the number of affected rows.

  • Stored Procedure
  • INSERT statement
  • UPDATE statement
  • DELETE statement
Dapper - Execute Example

string sql = "INSERT INTO Customers (CustomerName) Values (@CustomerName);";

using (var connection = new SqlCeConnection("Data Source=SqlCe_W3Schools.sdf"))
{
    var affectedRows = connection.Execute(sql, new {CustomerName = "Mark"});
}

Try it

Dapper - Query

Execute a query and map the result.

Dapper - Query Example

string sql = "SELECT * FROM OrderDetails";

using (var connection = new SqlCeConnection("Data Source=SqlCe_W3Schools.sdf"))
{
    var orderDetails = connection.Query(sql).ToList();

    Console.WriteLine(orderDetails.Count);
}

Try it

Dapper - Parameters

Use parameter in your Dapper query.

Dapper - Parameter Example

string sql = "INSERT INTO Customers (CustomerName) Values (@CustomerName);";

using (var connection = new SqlCeConnection("Data Source=SqlCe_W3Schools.sdf"))
{
    var affectedRows = connection.Execute(sql, new {CustomerName = "Mark"});

    Console.WriteLine(affectedRows);
}

Try it

Dapper - Result

Map the query result to different types.

Dapper - Result Example

string sql = "SELECT * FROM OrderDetails";

using (var connection = new SqlCeConnection("Data Source=SqlCe_W3Schools.sdf"))
{
    var orderDetails = connection.Query<OrderDetail>(sql).ToList();

    Console.WriteLine(orderDetails.Count);
}

Try it

Consulting

Your company requires some custom solution to extend Dapper with more features?

Contact us to learn about our consultation services:
info@zzzprojects.com

You can also find some answers/ help if:

Stack Overflow Issue tracker