Book Image

Apps and Services with .NET 8 - Second Edition

By : Mark J. Price
5 (7)
Book Image

Apps and Services with .NET 8 - Second Edition

5 (7)
By: Mark J. Price

Overview of this book

Elevate your practical C# and .NET skills to the next level with this new edition of Apps and Services with .NET 8. With chapters that put a variety of technologies into practice, including Web API, gRPC, GraphQL, and SignalR, this book will give you a broader scope of knowledge than other books that often focus on only a handful of .NET technologies. You’ll dive into the new unified model for Blazor Full Stack and leverage .NET MAUI to develop mobile and desktop apps. This new edition introduces the latest enhancements, including the seamless implementation of web services with ADO.NET SqlClient's native Ahead-of-Time (AOT) support. Popular library coverage now includes Humanizer and Noda Time. There’s also a brand-new chapter that delves into service architecture, caching, queuing, and robust background services. By the end of this book, you’ll have a wide range of best practices and deep insights under your belt to help you build rich apps and efficient services.
Table of Contents (19 chapters)
18
Index

What this book covers

Introduction

Chapter 1, Introducing Apps and Services with .NET, is about setting up your development environment and using Visual Studio 2022, Visual Studio Code, or JetBrains Rider. You will also learn about some good places to look for help, and ways to contact me (the author of this book) to get help with an issue or give me feedback to improve the book. The online-only sections review the new features added to the language and libraries in modern C# and .NET, how to benchmark the performance of your code, and how to work with types for reflection and attributes, expression trees, and dynamically generating source code during the compilation process.

Data

Chapter 2, Managing Relational Data Using SQL Server, is about setting up SQL Server on Windows or in the Azure cloud using SQL Database. (An online-only section shows how to set SQL Server up in a Docker container on Windows, macOS, or Linux.) You will then set up an example database for a fictional organization named Northwind. You will learn how to read and write at a low level using ADO.NET libraries (Microsoft.Data.SqlClient) for maximum performance, and then by using the object-to-data-store mapping technology named Dapper for ease of development.

Chapter 3, Building Entity Models for SQL Server Using EF Core, is about using the higher-level object-to-data-store mapping technology named Entity Framework Core (EF Core). You will create class libraries to define an EF Core model to work with the Northwind database that you created in Chapter 2. These class libraries are then used in many of the subsequent chapters.

Chapter 4, Managing NoSQL Data Using Azure Cosmos DB, is about the cloud-native non-SQL data store Azure Cosmos DB. You will learn how to read and write using its native API. An online-only section also covers the more specialized graph-based Gremlin API.

Libraries

Chapter 5, Multitasking and Concurrency, shows how to allow multiple actions to occur at the same time to improve performance, scalability, and user productivity by using threads and tasks.

Chapter 6, Implementing Popular Third-Party Libraries, discusses the types that allow your code to perform common practical tasks, like formatting text and numbers using Humanizer, manipulating images with ImageSharp, logging with Serilog, mapping objects to other objects with AutoMapper, making unit test assertions with FluentAssertions, validating data with FluentValidation, and generating PDFs with QuestPDF.

Chapter 7, Handling Dates, Times, and Internationalization, covers the types that allow your code to perform common tasks like handling dates and times, time zones, and globalizing and localizing data and the user interface of an app for internationalization. To supplement the built-in date and time types, we look at the benefits of using the much better Noda Time third-party library.

Services

Chapter 8, Building and Securing Web Services Using Minimal APIs, introduces the simplest way to build web services using ASP.NET Core Minimal APIs. This avoids the need for controller classes. You will learn how to improve startup time and resources using native AOT publish. You will then learn how to protect and secure a web service using rate limiting, CORS, and authentication and authorization. You will explore ways to test a web service using the new HTTP editor in Visual Studio 2022 and the REST Client extension for Visual Studio Code. An online-only section introduces building services that quickly expose data models using Open Data Protocol (OData).

Chapter 9, Caching, Queuing, and Resilient Background Services, introduces service architecture design, adding features to services that improve scalability and reliability like caching and queuing, how to handle transient problems, and how to implement long-running services by implementing background services.

Chapter 10, Building Serverless Nanoservices Using Azure Functions, introduces you to Azure Functions, which can be configured to only require server-side resources while they execute. They execute when they are triggered by an activity like a message sent to a queue, a file uploaded to storage, or at a regularly scheduled interval.

Chapter 11, Broadcasting Real-Time Communication Using SignalR, introduces you to SignalR, a technology that enables a developer to create a service that can have multiple clients and broadcast messages to all of them or a subset of them live in real time, for example, notification systems and dashboards that need instantly up-to-date information like stock prices.

Chapter 12, Combining Data Sources Using GraphQL, introduces building services that provide a simple single endpoint for exposing data from multiple sources to appear as a single combined source of data. You will use the ChilliCream GraphQL platform to implement the service, which includes Hot Chocolate. New in this edition is how to implement paging, filtering, sorting, and subscriptions.

Chapter 13, Building Efficient Microservices Using gRPC, introduces building microservices using the efficient gRPC standard. You will learn about the .proto file format for defining service contracts and the Protobuf binary format for message serialization. You will also learn how to enable web browsers to call gRPC services using gRPC JSON transcoding. New to this edition is how to improve the startup and memory footprint of a gRPC service with native AOT publish, handling custom data types including non-supported types like decimal, and implementing interceptors and handling faults.

Apps

Chapter 14, Building Web User Interfaces Using ASP.NET Core, is about building web user interfaces with ASP.NET Core MVC. You will learn Razor syntax, tag helpers, and Bootstrap for quick user interface prototyping.

Chapter 15, Building Web Components Using Blazor, is about how to build user interface components using the new unified full-stack hosting of Blazor introduced in .NET 8. Blazor components can now be individually configured to execute on the client- and server-side in the same project. For times when you need to interact with browser features like local storage, you will learn how to perform JavaScript interop. An optional online-only section, Leveraging Open-Source Blazor Component Libraries, introduces some popular open-source libraries of Blazor components.

Chapter 16, Building Mobile and Desktop Apps Using .NET MAUI, introduces you to building cross-platform mobile and desktop apps for Android, iOS, macOS, and Windows. You will learn the basics of XAML, which can be used to define the user interface for a graphical app. An online-only section, Implementing Model-View-ViewModel for .NET MAUI, covers best practice for architecting and implementing graphical apps by using Model-View-ViewModel. You will also see the benefits of using MVVM Toolkit and .NET MAUI Community Toolkit. Another online-only section, Integrating .NET MAUI Apps with Blazor and Native Platforms, covers building hybrid native and web apps that make the most of the operating system they run on. You will integrate native platform features like the system clipboard, filesystem, retrieve device and display information, and pop-up notifications. For desktop apps, you will add menus and manage windows.

Conclusion

Epilogue, describes your options for learning more about building apps and services with C# and .NET, and tools and skills you should learn to become a well-rounded professional .NET developer. An online-only section, Introducing the Survey Project Challenge, documents the product requirements for a survey/polling software solution that the reader can optionally attempt to implement and publish to a public GitHub repository to get feedback from the author and other readers.

Appendix, Answers to the Test Your Knowledge Questions, has the answers to the test questions at the end of each chapter.

You can read the appendix at the following link: https://github.com/markjprice/apps-services-net8/blob/main/docs/B19587_Appendix.pdf.