Dapper.NET is an open source, high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc, from Stack Overflow team. Drapper provides extension methods for IDbConnection, so you require an instance of IDbConnection to use Dapper. To use Dapper, you need to include Dapper in the project.json file. In this post I am using Repository pattern and injecting the repository to the controller via constructor injection.
Here is the project.json file, the EntityFramework.SqlServer reference is required to use IDbConnection interface.
Here is the constructor of the respository class. In this I am creating the instance of SqlConnection.
Dapper extends the IDbConnection with Query method, which you can use to execute a query and map the result to a strongly typed object or list of objects.
You can use Execute method to execute DML queries as well to the Database.
Dapper also supports Stored Procedures as well. You need to provide the command type parameter.
You can use Dapper in ASP.NET or any .net applications, for that you need to include the Dapper nuget reference. You can find more details about Dapper from Dapper wiki
Happy Programming :)
Did you like this article? Share it with your friends