What is Dapper :

Dapper is simple/ micro ORM for the .NET world. It’s a NuGet library that can be added to any .NET project for database operations. ORM stands for Object Relational Mapping, meaning the entire database can be operated in terms of OO classes, Interfaces etc. ORM creates a “virtual database” in terms of classes and provides methods to work with those classes. Dapper is a Micro ORM as it’s architected to focus on the most important task of working with database tables instead of creating, modifying the database schema, tracking changes etc.

Advantages :

  1. Dapper is a NuGet library, can be used with any .NET project. Quite lightweight, high performance.
  2. Drastically reduces the database access code.
  3. Focus on getting database tasks done instead of being full-on ORM. We cover more on this.
  4. Work with any database — SQL Server, Oracle, SQLite, MySQL, PostgreSQL etc.
  5. For an existing database, using Dapper is an optimal choice.
  6. AutoMapping feature.

Choosing Dapper over EF Core :

  1. Existing database with lots of stored procedure fetching a good amount of records.
  2. Developer’s familiarity in working with raw SQL or ADO.NET.
  3. The application mainly involves fetching for dashboards, reports.

How to use (Basic CRUD Operation) — Step by Step :

  1. Create a Database named StudentDB.
  2. Create Table named Student.
Image for post

3. Create a Store Procedure named SP_Student.

4. Create a ASP.NET Core Web API Project.

5. Create a Student Model Class.

Image for post

6. Create Student API Controller named StudentsController.cs.

7. Create interface named IStudentService.cs

Image for post

8. Create StudentService.cs Class and inherit it with IStudentService.cs

Image for post

Insert and Update Operation :

At Controller :

Image for post

At StudentService :

Image for post

Get Operation :

At Controller :

Image for post

At StudentService :

Image for post

Delete Operation :

At Controller :

Image for post

At StudentService :

Image for post

Done. Happy Coding…

VIDEO TUTORIALS YOU MAY LIKE :

  1. JWT Auth ASP.NET Core
  2. Dapper CRUD with ASP.NET Core Web API and Store Procedure.
  3. Angular Auth with ASP.NET Core
  4. Create and Use Session ASP.NET Core
  5. Generate and Download PDF in ASP.NET Core

Popular Tutorial Playlists :

  1. All CRUD operations
  2. Xamarin Tutorial series
  3. ASP.NET Core
  4. BLAZOR Tutorial
  5. ASP.Net MVC
  6. Web API
  7. Entity Framework
  8. Reporting
  9. SQL Server
  10. Angular 8
  11. Angular 4
  12. Angular 2
  13. AngularJS
  14. C# Desktop app
  15. LINQ