The About
component we were creating consumes the Person
entity, which contains a lot of information that is not necessary for the component, but still it is processed and returned to the View
. We can see in the following code, the AboutComponent
consumes the GetPersonByIdQuery
and returns the entire Person
entity to theView
:
public IViewComponentResult Invoke(int id) { var user = _repository.GetSingle( new GetPersonByIdQuery(_context) { IncludeData = true, Id = id }); return View(user); }
The preceding View
component renders only the Name
and Biography
properties of the user entity. We can see them in the following view component code:
<h2>About @Model.Name</h2> <p> @Model.Biography </p>
The View
component then consumes the data to render only the FirstName
and Biography
of the Person
entity. It is obvious that we need to address this problem, as we are returning unnecessary...