Reading data using Dapper
In this section, we are going to write some C# code that reads data from the database.
We are going to use the popular repository design pattern to structure our data access code. This will allow us to provide a nice, centralized abstraction of the data layer.
We are going to start by creating a data repository class that will hold all of the queries we are going to make to the data. We are going to create C# classes that hold the data we get from the database, called models.
We will implement methods for getting all the questions, getting questions from a search, getting unanswered questions, getting a single question, getting information stating whether a question exists, and getting an answer.
Creating the repository class
Let's create a class that will hold all of the methods for interacting with the database:
- In Solution Explorer, right-click on our project, select the Add menu,...