Introduction
This extension adds a Visual Studio C# library project template (DAL) Data Access Layer that helps with working and connecting to the SQL server database using an app.config file connection string. It also contains methods that create and gets the data from the database and saves data to the database using data model classes and Dapper ORM.
Dapper DAL Project
This is a Visual Studio project template that creates a C# library project with classes and interfaces and methods to work as "Data Access Layer" using Dapper ORM.
v1.0
Support for Visual Studio 2017.
V1.1
Support for Visual Studio 2019.
Preview


Part One - Setup Projects
First, set up your project
- Create your project.
- Open your project app.config file add the connection string of your server.
Next, set up your Dapper Project
Open DataAccess\SqlConnector.cs File and change the db const varibale value to your connection string name in your app.config file.
Part Two - Wire Up Projects
- Add the dapper DAL library as a reference in your project.
- Open your program.cs or any file you want to use as connection Initializer in your project, and add this code :
Note
First, add a using statement for the dapper library.
- GlobalConfig.InitializeConnection(new SqlConnector());
Part Three - Perform Action on Data Base
Use Create(dataModel,commandText,commandType) method to insert , update , delete in your database, and use Get (commandText, commandType) method to get data from database.
Those methods are implemented from IDataConnection interface in SqlConnector class.
This is how they look:

Join the conversation! Your thoughts help the community grow.