Add item for page 654

This commit is contained in:
Mark J Price 2023-03-04 07:45:52 +00:00
parent 3c8e293361
commit 905b96e79d
4 changed files with 15 additions and 4 deletions

View file

@ -4,6 +4,6 @@ If you find any mistakes in the seventh edition, *C# 11 and .NET 7 - Modern Cros
[**Errata** (31 items)](errata.md): Typos, tool user interface changes, or mistakes in code that would cause a compilation error that prevents a successful build.
[**Improvements** (10 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
[**Improvements** (11 items)](improvements.md): Changes to text or code that would improve the content. These are optional.
All errata and improvements will be included in the 8th edition planned for publishing in November 2023. To be included they must be submitted by mid-September 2023.

View file

@ -1,4 +1,4 @@
**Improvements** (10 items)
**Improvements** (11 items)
If you have suggestions for improvements, then please [raise an issue in this repository](https://github.com/markjprice/cs11dotnet7/issues) or email me at markjprice (at) gmail.com.
@ -11,6 +11,7 @@ If you have suggestions for improvements, then please [raise an issue in this re
- [Page 453 - Scaffolding models using an existing database](#page-453---scaffolding-models-using-an-existing-database)
- [Page 547 - Creating a class library for a Northwind database context](#page-547---creating-a-class-library-for-a-northwind-database-context)
- [Page 551 - Creating a class library for entity models using SQL Server](#page-551---creating-a-class-library-for-entity-models-using-sql-server)
- [Page 654 - Making controller action methods asynchronous](#page-654---making-controller-action-methods-asynchronous)
- [Page 655 - Exercise 14.2 Practice implementing MVC by implementing a category detail page](#page-655---exercise-142--practice-implementing-mvc-by-implementing-a-category-detail-page)
# Page 86 - Getting text input from the user
@ -291,6 +292,16 @@ public static IServiceCollection AddNorthwindContext(
}
```
# Page 654 - Making controller action methods asynchronous
In an earlier task, you imported the `Microsoft.EntityFrameworkCore` namespace so that you could use the `Include` extension method. In Step 1, I tell you to use the `ToListAsync` method to implement the `Index` action method asynchronously. If you had not previously imported the `Microsoft.EntityFrameworkCore` namespace then you would have to import it now to use the `ToListAsync` method.
In the next edition, I will add a comment to make this more obvious, as shown in the following code:
```cs
using Microsoft.EntityFrameworkCore; // To use the Include and ToListAsync extension methods.
```
# Page 655 - Exercise 14.2 Practice implementing MVC by implementing a category detail page
Earlier in the chapter, and in Exercise 14.2, the link generated for a category detail page looks like this:

View file

@ -3,7 +3,7 @@ using Northwind.Mvc.Models; // ErrorViewModel
using System.Diagnostics; // Activity
using Microsoft.AspNetCore.Authorization; // [Authorize]
using Packt.Shared; // NorthwindContext
using Microsoft.EntityFrameworkCore; // Include extension method
using Microsoft.EntityFrameworkCore; // Include and ToListAsync extension methods
namespace Northwind.Mvc.Controllers
{

View file

@ -3,7 +3,7 @@ using Northwind.Mvc.Models; // ErrorViewModel
using System.Diagnostics; // Activity
using Microsoft.AspNetCore.Authorization; // [Authorize]
using Packt.Shared; // NorthwindContext
using Microsoft.EntityFrameworkCore; // Include extension method
using Microsoft.EntityFrameworkCore; // Include and ToListAsync extension methods
namespace Northwind.Mvc.Controllers
{