December 2019
Intermediate to advanced
598 pages
12h 21m
English
We want to interact with an instance of the data repository we created in the previous chapter into our API controller. Let's carry out the following steps to do this:
using QandA.Data;using QandA.Data.Models;
[Route("api/[controller]")][ApiController]public class QuestionsController : ControllerBase{ private readonly IDataRepository _dataRepository;}
We've used the readonly keyword to make sure the variable's reference doesn't change outside the constructor.
Read now
Unlock full access