By using Dapper, we can significantly reduce the amount of coding required for database writes. In this instance, I am using MySQL - Best Buy database (totally made up fields of course 🤖 ) as an example.
I created a .Net Core Console Application, added appsettings.json (with Git ignore), then added 3 Nuget packages: Dapper, Microsoft.Extensions.Configuration.Json package, and MySql.Data to config and connection string. I then created using C# the Class, IEnumerable Repository Interface, Repository Class, and Methods.
Dapper is a .NET compatible, NuGet library ORM that you can add to your project that will extend your IDbConnection interface. The Dapper Execute is designed for any database writes, like INSERT, UPDATE, and DELETE.
Here is a side by side comparison of just using MySqlConnection (left) vs using Dapper (right): You might notice how much code is reduced by using the Dapper implementation!I implemented ORM Dapper into my final project so please check it out! https://github.com/nancylee1/FinalProject.ASP.NET.CoreMVC-LoveLeeLuxWebStore
Feel free to connect with me here on GitHub or on LinkedIn (www.linkedin.com/in/nancylee7). Thanks for checking this out!