From the course: Building Web APIs with ASP.NET Core 8
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Making the API asynchronous
From the course: Building Web APIs with ASP.NET Core 8
Making the API asynchronous
- [Instructor] And finally, since we are working with the data store so much, we may want to make our actions asynchronous. That's a rather easy task thanks to what .NET offers us. All we need to do is change the method signature. So instead of public IEnumerable of product, we can do public async task of IEnumerable of product, and then we have to call await within that method whenever we have another asynchronous call. So for instance, if we call ToList on the products that we receive via Entity Framework Core, we could do this asynchronously because then when we call ToList, the data from data store is materialized so we can access it. Entity Framework Core tries to do that as late as possible because anything we change in our query could change the sequel that is then sent to the data store. And therefore this materialization phase is always important and can also take a tiny bit of time, and therefore an asynchronous call might be a good idea. Also, when working with…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Controllers and actions7m 50s
-
(Locked)
Routing basics6m 14s
-
(Locked)
Creating a data model5m 54s
-
(Locked)
Using entity framework core7m 28s
-
(Locked)
Returning a list of items4m 4s
-
(Locked)
Using ActionResult2m 44s
-
(Locked)
Returning an item4m 29s
-
(Locked)
Handling errors3m 5s
-
(Locked)
Making the API asynchronous2m 51s
-
(Locked)
Working with minimal APIs5m 22s
-
(Locked)
Challenge: Searching items31s
-
(Locked)
Solution: Searching items3m 1s
-
(Locked)
-
-