nancylee1 / BestBuyBestPractices-ORM_DAPPER

💻MySQL Best Buy Database - ORM & DAPPER - By using Dapper, we can significantly reduce the amount of code required for database writes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

💻 MySQL Best Buy Database - ORM & DAPPER

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.

Reduce the amount of Code you write with Dapper:

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!

sql vs dapper

Here's a snippet of the command when run:

console1 console2

Here's a snippet of My SQL:

sql

Here's a snippet of my C# Code:

code

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!

About

💻MySQL Best Buy Database - ORM & DAPPER - By using Dapper, we can significantly reduce the amount of code required for database writes.


Languages

Language:C# 100.0%