Book Image

Software Architecture with C# 9 and .NET 5 - Second Edition

By : Gabriel Baptista, Francesco Abbruzzese
Book Image

Software Architecture with C# 9 and .NET 5 - Second Edition

By: Gabriel Baptista, Francesco Abbruzzese

Overview of this book

Software architecture is the practice of implementing structures and systems that streamline the software development process and improve the quality of an app. This fully revised and expanded second edition, featuring the latest features of .NET 5 and C# 9, enables you to acquire the key skills, knowledge, and best practices required to become an effective software architect. This second edition features additional explanation of the principles of Software architecture, including new chapters on Azure Service Fabric, Kubernetes, and Blazor. It also includes more discussion on security, microservices, and DevOps, including GitHub deployments for the software development cycle. You will begin by understanding how to transform user requirements into architectural needs and exploring the differences between functional and non-functional requirements. Next, you will explore how to carefully choose a cloud solution for your infrastructure, along with the factors that will help you manage your app in a cloud-based environment. Finally, you will discover software design patterns and various software approaches that will allow you to solve common problems faced during development. By the end of this book, you will be able to build and deliver highly scalable enterprise-ready apps that meet your organization’s business requirements.
Table of Contents (26 chapters)
24
Another Book You May Enjoy
25
Index

Understanding Entity Framework Core advanced features

An interesting Entity Framework advanced feature that is worth mentioning is global filters, which were introduced at the end of 2017. They enable techniques such as soft delete and multi-tenant tables that are shared by several users, where each user just sees its records.

Global filters are defined with the modelBuilder object, which is available in the DbContext OnModelCreating method. The syntax for this method is as follows:

modelBuilder.Entity<MyEntity>().HasQueryFilter(m => <define filter condition here>);

For instance, if we add an IsDeleted property to our Package class, we may soft delete a Package without removing it from the database by defining the following filter:

modelBuilder.Entity<Package>().HasQueryFilter(m => !m.IsDeleted);

However, filters contain DbContext properties. Thus, for instance, if we add a CurrentUserID property to our DbContext subclass (whose...