.NET Web entry to advanced route (new version)

.NET Web entry to advanced route

C# basic syntax

Microsoft's official tutorial address: C# Documentation - Getting Started, Tutorial, Reference. | Microsoft Learn

B station video:

Complete Works of Liu Tiemeng's "Detailed Introduction to C# Language"_哔哩哔哩_bilibili

Detailed introduction to C# language

.NET Core Fundamentals

Microsoft official tutorial address: Create Web API with ASP.NET Core | Microsoft Learn

.NET 6 Tutorial, .Net Core 2022 Video Tutorial, Lectured by Yang Zhongke_哔哩哔哩_bilibili

Overview of ASP.NET Core Basics

Blazor

Blazor is a framework for generating interactive client-side web UIs using Blazor:

  • Use C# instead of JavaScript to create informative, interactive UIs.
  • Share server-side and client-side application logic written in .NET.
  • Renders the UI to HTML and CSS to support a wide range of browsers, including mobile browsers.
  • Integrate with modern hosting platforms like Docker .
  • Build hybrid desktop and mobile apps using .NET and Blazor.

Using .NET for client-side web development offers the following advantages:

  • Use C# instead of JavaScript to write code.
  • Leverage the existing .NET library ecosystem.
  • Share application logic between server and client.
  • Benefit from the performance, reliability, and security of .NET.
  • Stay productive on Windows, Linux or macOS using a development environment such as Visual Studio or Visual Studio Code .
  • Build on a stable, feature-rich, and easy-to-use set of common languages, frameworks, and tools.

Blazor Microsoft Official Documentation

Blazor basic tutorial B station video tutorial

Provides a lot of related documents of Blazor ecology

Recommended Blazor UI framework

ASP.NET Core Official Documentation

GitHub / Web VSCode address

ORM

Introduction to ORM
The Object Relational Mapping (ORM) pattern is a technology to solve the mismatch between object-oriented and relational databases.

Simply put, ORM automatically persists the objects in the program to the relational database by using the metadata describing the mapping between the object and the database.

So, how to achieve persistence? A simple solution is to hardcode each possible database access operation with a separate method.

This solution has the following shortcomings:
1. The persistence layer lacks flexibility. Once there is a change in business requirements, the interface of the persistence layer must be modified.
2. The persistence layer is bound to the domain model and the relational database model at the same time. No matter whether the domain model or the relational database model changes, the poison will modify the relevant program code of the persistence layer. , increasing the difficulty of software maintenance.

  • Simple: Model data in its most basic form.
  • Communicative: The database structure is documented in a language that anyone can understand.
  • Accuracy: Create correctly normalized structures based on the data model.

FreeSql

It is a powerful object-relational mapping (O/RM) component that supports .NET Core 2.1+, .NET Framework 4.0+ and Xamarin✨

EntityFrameworkCore

Entity Framework (EF) Core is a lightweight, extensible, open source, and cross-platform version of the popular Entity Framework data access technology. (The author recommends that efcore is officially maintained by Microsoft)

Dapper

Dapper is a micro-ORM created by the team behind Stack Overflow. Dapper, a simple object mapper for .NET, is the king of Micro ORMs when it comes to speed, almost as fast as using raw ADO.NET data readers. ORM is an Object Relational Mapper responsible for mapping between databases and programming languages.

SqlSugar

SqlSugar is an old .NET open source ORM framework, maintained and updated by the fructose big data technology team

Relational Database

SQL Server

SQL Server is a relational database management system (DBMS) developed and promoted by Microsoft ;
SQL Server is easy to use, has good scalability and a high degree of integration with related software;
SQL Server database engine provides a more secure and reliable database for relational data and structured data storage function.

MySQL

MySQL is the most popular relational database management system, and MySQL is one of the best RDBMS (Relational Database Management System: Relational Database Management System) application software in terms of WEB applications.

PostgreSQL

PgSQL A brief history of PostgreSQL. The object-relational database management system now known as PostgreSQL (and for a while known as Postgres95) was developed from the POSTGRES package written at Berkeley. . After more than ten years of development, PostgreSQL is the most advanced open source database system available in the world. It provides multi-version parallel control and supports almost all SQL components (including subqueries, transactions and user-defined types and functions) , and a very wide range of (development) language bindings are available (including C, C++, Java, perl, tcl, and python)

middleware

Middleware is a type of software between the application system and system software. It uses the basic services (functions) provided by the system software to connect various parts of the application system or different applications on the network, and can achieve resource sharing and function sharing. the goal of. It does not have a strict definition, but the definition of IDC is generally accepted: middleware is an independent system software service program, distributed application software uses this software to share resources between different technologies, middleware is located on the client server On top of the operating system, it manages computing resources and network communications. In this sense, middleware can be represented by an equation: middleware = platform + communication, which limits that it can only be called middleware when it is used in a distributed system, and also distinguishes it from supporting software and practical software. Come.

MongoDB

MongoDB is a database based on distributed file storage. Written in C++ language. Designed to provide scalable high-performance data storage solutions for WEB applications.

MongoDB is a product between relational databases and non-relational databases. It is the most functional among non-relational databases and most similar to relational databases.

Redis

REmote DIctionary Server (Redis) is a key-value storage system written by Salvatore Sanfilippo, which is a cross-platform non-relational database.

Redis is an open source, written in ANSI C language, complies with the BSD protocol, supports the network, can be based on memory, distributed, optional persistent key-value pair (Key-Value) storage database, and provides APIs in multiple languages.

Redis is often referred to as a data structure server because values ​​can be of types such as strings, hashes, lists, sets, and sorted sets.

RabbitMQ

RabbitMQ is an open source message broker software (also known as message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ server is written in the Erlang language, while the clustering and failover are built on the Open Telecom Platform framework. All major programming languages ​​have client libraries for communicating with broker interfaces.

ActiveMQ

Apache ActiveMQ is an open source message middleware developed by the Apache Software Foundation; since ActiveMQ is a pure Java program, ActiveMQ can be executed only if the operating system supports the Java virtual machine.

SkyWalking

Application performance monitoring tool for distributed systems, especially designed for microservices, cloud-native and container-based (Kubernetes) architectures.

Consul

Consul is a distributed middleware that solves service discovery and configuration centers in the microservice architecture.
Consul is an open source tool launched by HashiCorp. Consul is developed by Go language. It is very easy to deploy, requires only a few executable programs and configuration files, and is green and lightweight. Consul is a distributed, highly available, and horizontally scalable service discovery and configuration for distributed systems.

  • Service Discovery: Consul provides a way to register and discover services through DNS or HTTP interfaces. Some external services can easily find the services it depends on through Consul.
  • Health Checking (Health Checking): Consul's Client can provide any number of health checks, which can be associated with a given service ("whether the webserver returns 200 OK") or associated with the local node ("whether the memory utilization less than 90%"). Operators can use this information to monitor the health of the cluster, and service discovery components can use this information to route traffic away from unhealthy hosts.
  • Key/Value storage: Applications can use the Key/Value storage provided by Consul according to their needs. Consul provides a simple and easy-to-use HTTP interface, which can be combined with other tools to realize dynamic configuration, function marking, leader election and other functions.
  • Secure service communication: Consul can generate and distribute TLS certificates for services to establish mutual TLS connections. Intents can be used to define which services are allowed to communicate. Service segmentation can be easily managed, and its intent can be changed in real time, rather than using complex network topologies and static firewall rules.
  • Multiple data centers: Consul supports out-of-the-box multiple data centers. This means that users don't need to worry about the need to build additional abstraction layers to allow business expansion to multiple regions.

Kafka

Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action streaming data in consumer-scale websites. Such actions (page browsing, searching, and other user actions) are a key factor in many social functions on the modern web. These data are usually addressed by processing logs and log aggregation due to throughput requirements. This is a viable solution for systems like Hadoop that log data and analyze offline, but require real-time processing constraints. The purpose of Kafka is to unify online and offline message processing through Hadoop's parallel loading mechanism, and to provide real-time consumption through cluster machines.

according to

Dapr is a portable, event-driven runtime that enables any developer to easily build elastic, stateless and stateful applications that can run on cloud platforms or edge computing, and it also supports multiple programming languages ​​and development frameworks.

Introduction to Microsoft Dapr

operation and maintenance

Docker

Docker is an open source application container engine, based on the Go language and open source in compliance with the Apache2.0 protocol.

Docker allows developers to package their applications and dependencies into a lightweight, portable container, which can then be distributed to any popular Linux machine, and can also be virtualized.

The container is completely using the sandbox mechanism, and there will be no interface between them (similar to iPhone apps), and more importantly, the performance overhead of the container is extremely low.

DockerCompose

Compose is a tool for defining and running multi-container Docker applications. With Compose, you can use YML files to configure all the services your application needs. Then, with a single command, all services can be created and started from the YML file configuration.

Drone

Drone is a self-service continuous integration platform for busy development teams.

CI/CD

CI continuous integration (Continuous Integration)
collaborative development is currently the mainstream development method, that is, multiple developers can simultaneously process different modules or functions of the same application.

However, if the enterprise plans to integrate all the development branch code together on the same day, it may end up taking a lot of time and a lot of duplication of effort, which is laborious and laborious. Because code conflicts are inevitable.

If the developer's local environment is inconsistent with the online environment, then the problem is even more complicated.

Continuous Integration (CI) helps developers merge code changes into the master branch more easily.

Once the developer merges the changed code into the master branch, the system verifies the changes by automatically building the application and running different levels of automated tests (usually unit and integration tests) to ensure that the changes did not break the application.

If automated tests find conflicts between new and existing code, CI makes it easier to quickly fix those bugs.

CD Continuous Delivery (Continuous Delivery)
CI After completing the automated processes of construction, unit testing, and integration testing, continuous delivery can automatically release the verified code to the enterprise's own repository.

Continuous delivery aims to build a code base ready to deploy the functionality of the development environment to the production environment.

In the continuous delivery process, each step involves test automation and code release automation.

At the end of the process, operations teams can quickly and easily deploy the application into production.

CD Continuous Deployment (Continuous Deployment)
For a complete and mature CI/CD pipeline, the final stage is continuous deployment.

It is an extension of continuous delivery, which can automatically release applications to the production environment.

In fact, continuous deployment means that changes to the application by developers can be implemented in a timely manner within minutes of writing (provided that it passes automated tests). This makes it easier for the operations team to continuously receive and integrate user feedback.

All in all, all these CI/CD associated steps greatly reduce the deployment risk of the application.

Still, there is a lot of upfront work, since automated tests also need to be written to accommodate the various testing and release phases in the CI/CD pipeline.

microservice

A software development technique - A variation of the Service-Oriented Architecture (SOA) architectural style that advocates dividing a single application into a set of small services that coordinate and work together to provide ultimate value to users. Each service runs in its own independent process, and services communicate with each other using a lightweight communication mechanism (usually an HTTP-based RESTful API). Each service is built around a specific business and can be independently deployed to production environments, production-like environments, etc. In addition, a unified and centralized service management mechanism should be avoided as much as possible. For a specific service, an appropriate language and tool should be selected to build it according to the context.

.NET Application Architecture Documentation

.NET microservices. suitable for containerization

Reduce business complexity in microservices using DDD and CQRS patterns
image

Domain Driven Design (DDD)

Domain-Driven Design (DDD) advocates building models based on real business related use cases. In the context of building applications, DDD uses domains to describe problems. It describes independent problem areas as bounded contexts (each bounded context is associated with a microservice), and emphasizes the use of a common language to discuss these issues. It also proposes many technical concepts and patterns, such as domain entities with anemic models (without anemic models), value objects, aggregates, and aggregate root (or root entity) rules for supporting internal implementations. This section describes the design and implementation of these internal patterns.

Sometimes these DDD technical rules and patterns are considered obstacles because they cause a steep learning curve when implementing a DDD approach. But the important thing is not the pattern itself, but how to organize the code according to the business problem, and use the same business term (universal language). Also, the DDD approach should only be used when implementing complex microservices with significant business rules. Simpler functions, such as CRUD services, can be managed using simpler methods.

When designing and defining microservices, the most critical task is to define boundaries. With the help of DDD patterns, you can understand the complexity in the domain. For each bounded context's domain model, identify and define the entities, value objects, and aggregates needed to model the domain. Generate and refine a domain model bounded within a boundary that defines the context. If it is in the form of microservices, this will be very clear. Components within these boundaries end up as microservices, but in some cases a BC or business microservice can consist of multiple physical services. DDD is about boundaries, and so are microservices.

Implement read/query in CQRS microservices

For read/query, the ordering microservice from the eShopOnContainers reference application implements the query independently of the DDD model and transaction area. This implementation is mainly because the needs of queries are very different from the needs of transactions. Written execution transactions must conform to domain logic. Queries, on the other hand, are idempotent and can be decoupled from domain rules.

application framework

ABP

ABP is an open-source and document-friendly application framework. ABP is not just a framework, it also provides the most practical domain-driven design (DDD)-based architecture model, which can support two technical genres of .net framework and .net core.

ABP framework features

  • Dependency injection, this part uses Castle windsor (dependency injection container) to achieve dependency injection, which is also the way we often use IOC to handle;
  • The Repository storage mode has implemented Entity Framework, NHibernate, MangoDB, memory database, etc. The storage mode can quickly realize the call to the data interface;
  • Authentication and authorization management, you can use the way of declaring characteristics to verify whether the user is logged in, or the authority of the interface, and you can set the calling authority of each interface in a very fine-grained way;
  • Data validity verification, ABP automatically judges whether the input parameter object of the interface is not empty, and can verify the validity of the attribute according to the application information of the attribute;
  • Audit log records, that is, record our call records for each interface, and record the creation, modification, and deletion of records, etc.;
  • The Unit Of Work work unit mode automatically implements database transactions for the methods of the application layer and storage layer. By default, all interfaces of the application service layer operate as a unit of work, even if they call different storage object processing, they are all in one Inside the logic of the transaction;
  • Exception handling, the ABP framework provides a complete set of process processing operations, which can easily record and transmit exceptions;
  • Logging, we can use Log4Net for regular logging, which is convenient for us to track program processing information and error messages;
  • Multi-language/localization support, the ABP framework is also friendly to multi-language processing, providing configuration processing for XML and JSON language information;
  • Auto Mapping automatic mapping, this is a very important object isolation concept of ABP, by using AutoMaper to realize the attribute mapping of domain objects and DTO objects, the logical relationship between the two can be isolated, but the assignment of attribute information can be easily realized;
  • Dynamic Web API layer, using this dynamic processing, can directly publish the Application Service as the Web API layer, without the need to manually create a Web API controller for each business object, which is very convenient;
  • The AJax proxy processing of dynamic JavaScript can automatically create a Javascript proxy layer to make it easier to use Web Api, which is used in the Web layer.

ABP framework special features

  • Multi-tenant support (the data of each tenant is automatically isolated, and business module developers do not need to write corresponding codes when saving and querying data;
  • Soft deletion support (inheriting the corresponding base class or implementing the corresponding interface will automatically implement soft deletion)
  • System setting access management (system level, tenant level, user level, scope automatic management)
  • EventBus implements domain events (Domain Events)
  • Modules and module dependencies realize plug-in module processing, etc.

image

MASA Framework

Brand-new .NET modern application development, providing distributed application runtime – based on Dapr cloud-native best practices, it can quickly realize distributed, micro-service, DDD, SaaS and other modern application development

image

OpenIddict

What is OpenIddict?

OpenIddict aims to provide a generic solution to implement OpenID Connect client, server and token authentication support in any ASP. NET Core 2.1 (and later) applications. ASP. NET 4.6.1 (and later) applications are also fully supported thanks to native Microsoft. Owin 4.2 integration.

OpenIddict fully supports code/implicit/hybrid flow, client credentials/resource owner password grant and device authorization flow.

OpenIddict natively supports Entity Framework Core, Entity Framework 6, and MongoDB, and can implement custom stores to support other providers.

end

Big guys are welcome to continue to add and expand the dotnet ecosystem!

GitHub address: dotent entry to advanced

Sharing from token

Technical exchange group: 737776595

Guess you like

Origin blog.csdn.net/xiaohucxy/article/details/130342203