Let's create some stored procedures that our app will use to interact with the database tables:
- Copy the contents of the SQL Script at https://github.com/PacktPublishing/ASP.NET-Core-3-and-React-17/blob/master/Chapter07/backend/SQLScripts/02-Sprocs.sql.
- Click New Query to create a new SQL query and paste in the contents from the copied script.
- Click the Execute option on the toolbar.
- If we look under Stored Procedures under Programmability in Object Explorer, we should see that several stored procedures have been created:
We'll be using these stored procedures to interact with the database from the ASP.NET Core app.
- Before we finish this section, let's try to run one of the stored procedures. Click New Query to create a new SQL query and enter the following:
EXEC dbo.Question_GetMany_BySearch @Search = 'type'
So, this SQL command will execute the Question_GetMany_BySearch stored procedure passing in the @Search parameter with a value of type. This stored procedure returns questions that have the value of the @Search parameter in the title or its content.
- Click the Execute option on the toolbar and we should get the following results:
With our SQL Server database in place, we can now turn our attention to Dapper.