My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

CRUD (Dapper + ASP.NET Core + Web API + Store Procedure)

Russel's photo
Russel
·Jun 4, 2020

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 : Dapper is a NuGet library, can be used with any .NET project. Quite lightweight, high performance. Drastically reduces the database access code. Focus on getting database tasks done instead of being full-on ORM. We cover more on this. Work with any database — SQL Server, Oracle, SQLite, MySQL, PostgreSQL etc. For an existing database, using Dapper is an optimal choice. AutoMapping feature. Choosing Dapper over EF Core : Existing database with lots of stored procedure fetching a good amount of records. Developer’s familiarity in working with raw SQL or ADO.NET. The application mainly involves fetching for dashboards, reports. How to use (Basic CRUD Operation) — Step by Step :

Full Video Tutorial Create a Database named StudentDB. Create Table named Student.

  1. Create a Store Procedure named SP_Student.
  2. Create a ASP.NET Core Web API Project.
  3. Create a Student Model Class.

  4. Create Student API Controller named StudentsController.cs.

  5. Create interface named IStudentService.cs

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

Done. Happy Coding…