December 2019
Intermediate to advanced
598 pages
12h 21m
English
Let's create the PutQuestion method in DataRepository.cs to change a question. This is very similar to the PostQuestion method we have just implemented:
public QuestionGetSingleResponse PutQuestion(int questionId, QuestionPutRequest question){ using (var connection = new SqlConnection(_connectionString)) { connection.Open(); connection.Execute( @"EXEC dbo.Question_Put @QuestionId = @QuestionId, @Title = @Title, @Content = @Content", new { QuestionId = questionId, question.Title, question.Content } ); return GetQuestion(questionId); }}
Notice that we use the Dapper Execute method because we are simply executing a stored procedure and not returning anything.
We've created the SQL parameters ...
Read now
Unlock full access