Using Dapper Multi-Mapping to Resolve the N+1 Problem

Learn to use Dapper multi-mapping to resolve the N+1 problem.

We'll cover the following

Wouldn't it be great if we could get the questions and answers in a single database query and then map this data to the hierarchical structure that we require in our data repository? Well, this is exactly what we can do with a feature called multi-mapping in Dapper. Let's look at how we can use this. Follow these steps:

  1. In the data repository, let's change the implementation of the GetQuestionsWithAnswers method to call a single stored procedure:

Get hands-on with 1400+ tech skills courses.