In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how the UnitOfWork data access mode in the Asp.Net Core work unit is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Some students may say that my current project has no project structure to speak of. Is that true? Why there is such a question.
Project architecture is constantly evolved according to their own actual business, in the process of exploration by the predecessors, so slowly refine do not sum up some experience (that is, design ideas), and finally form an architectural pattern.
Everything is reasonable, so your project must have a structure to speak of, but the current architecture may not better meet your business requirements, you need to evolve and upgrade.
What is project architecture layering?
What is the difference between system architecture layering and project architecture layering?
The literal meaning of these two concepts is easy to be confused, but these two concepts are really two different things. I hope you can distinguish them clearly.
System architecture layering: the point of view of the station is the hardware (physical) level (reverse proxy, forward proxy, third-party middleware).
Project architecture layering: the point of view is the software (logic) level (Code code level).
Advantages and disadvantages of classic three-tier architecture (3-Layer)
Advantages: simple layering, easy to use, code monkey monkeys are easy to use.
Cons: a lot of repetitive CRUD code.
A sentence that Ah Bun often says: erverything is price
Although the introduction of a new thing has solved the previous existing problem, it also has a price and will give rise to new problems.
As the name implies, the three-tier architecture is divided into three layers, namely, "data access layer", "business logic layer", and "presentation layer".
Data access layer (DAL): realize the operation of reading and saving data in the database.
Business Logic layer (BLL): it is the bridge between DAL and UI layer. Since it is called the business layer, it must have its use, not just a transit function.
Ah Ben's advice to everyone should keep in mind that the logic at the UI level can be placed on the UI layer, while the logic suggestions at the business level should be put on the business logic layer.
What on earth is the use of the business logic layer BLL?
Https://www.cnblogs.com/Garden-blog/archive/2011/04/12/2013268.html
Presentation layer (UI): the main function is to display data and accept data that transmits users, such as Windows forms and Web pages.
Advantages and disadvantages of Repository warehousing model
1) what is Repository?
Repository; Chinese translation for warehouse, we all know that there are many kinds of things in the warehouse, so you just need to take things from the warehouse, you do not have to care about the storage of things in the warehouse in that specific location. The caller does not ask or need to know, you are only responsible for getting it from the inside.
Generally combined with ORM framework, such as EF,Dapper and so on. Because such frameworks are born with highly reusable CRUD features.
Advantages:
1. CRUD achieves the goal of reuse (stripping out some common methods of calling the database and reducing redundant code).
2. Provide a unified specification for business development (program development). Everyone's code is standardized, according to the standard mode of operation, let the warehouse store (write code) their own things, when used, we can borrow from each other (share).
Disadvantages:
1) how can operations between multiple Repository be saved in a transaction unit?
UnitOfWork unit of work mode
1. What is a work unit?
Across multiple requested services, unified management of transactions, unified submission.
two。 Why do you need a work unit?
Our code is often layered, it is possible to new DbContext (options) everywhere, this is how to manage these DbContext, in AspNetCore services.AddDbContext default is to use the scope of Scope, that is, every HttpRequest, much better than before. But the management of affairs is still troublesome.
For example, in the figure above, an Action needs to call a lot of Service and then the Service calls each other. When you open Action, you actually want to open a transaction, but some internal code may open the transaction on its own. It is very troublesome to call and manage each other. There are often inestimable problems. It would be much better if there was a place of centralized management. For example, start a unit of work here in Action, and all subsequent businesses use the same transaction and DbContext, which is what we expect.
3. How to use the unit of work?
Http://www.aspnetboilerplate.com/Pages/Documents/Unit-Of-Work
Just remember that when the Commit () method in Unit Of Work executes, all changes that occur on objects in the repository Repository are committed to the database.
On the Asp.Net Core unit of work in the UnitOfWork data access mode is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.