12 Using IAsyncEnumerable<T> and yield return
This chapter covers
- Using the generic
Queue
data structure - Using
yield return
andIAsyncEnumerable<T>
- Creating Views
- Using private getters and setters with auto-properties
- How structs differ from classes
- Using
checked
andunchecked
keywords
In the previous chapters, we examined the code base we inherited and noted where we could make improvements. Then, we partially implemented our version of the code base, adhering to FlyTomorrow’s OpenAPI specification. In chapters 10 and 11, we implemented the BookingService
class and decided that there was no need for a CustomerService
class.
Figure 12.1 In this chapter we wrap up the services layer by implementing the AirportService and FlightService class. By implementing those classes, we finish the service layer rewrite of the Flying Dutchman Airlines service.

If we look at which classes we need to implement to complete our service layer, we see an encouraging picture:
CustomerService
(Chapter 10)BookingService
(Chapter 10 and 11)AirportService
(this chapter)FlightService
(this chapter)
We are halfway done with the service layer classes. In this chapter, we wrap up the service layer implementation by writing code for the AirportService
and FlightService
classes. After this chapter, we are in an excellent spot to move on to our last architectural layer: the controller layer.