MVC Project Practice: Implement SportsStore in a three-tier architecture, and view the three-tier architecture from the class diagram

Source: Internet
Author: User

MVC Project Practice: Implement SportsStore in a three-tier architecture, and view the three-tier architecture from the class diagram

In the comment on the article "MVC project practice, implementing SportsStore-02, DbSession layer, BLL layer" under the three-tier architecture, Boyou wave is suggested to use class diagrams to understand the three-tier architecture of the project. So we have this article:

 

IDAL Layer

 

→ IBaseRepository interface, basic interface, providing generic implementation

The methods at all data interface layers are basically the same, including query, paging query, addition, batch addition, update, batch update, deletion, and batch deletion. Therefore, it is necessary to extract basic interfaces for all data interfaces to provide generic implementation.

 

→ IProductRepository Interface

Implement the IBaseRepository interface.

 

→ IDbContextFactory interface, the abstract factory of the current EF Context

EF context must be used in the BaeRepository of DAL. We use IDbContextFactory as an "Abstract Factory" to produce DbContext instances.

 

→ IDbSession interface, a unified portal interface for the database access layer

I mainly did three things:
1. Submit all changes
2. Obtain the IXXXRepository types
3. Execute SQL statements

 

→ IDbSessionFactory interface, abstract factory of IDbSession Interface

The unified entry of the IDbSession data layer will be used in BLL's BaseService. We use IDbSessionFactory as the "Abstract Factory" to produce IDbSession instances.

 

DAL Layer

 

→ BaseRepository: All base classes of XXXRepository, providing generic implementation

BaseRepository does not need to implement IBaseRepository, because it exists to avoid repeated XXXRepository code. It provides generic implementations of XXXRepository.

After BaseRepository implements the IDisposable interface, it can be manually recycled.

 

→ ProductRepository

Derived from the BaseRepository <Product> base class.
Implements the IProductRepository interface. Its behavior is subject to IProductRepository constraints.

 

> DbContextFactory: implements the abstract factory IDbContextFactory interface to produce EF context instances.

The implementation process ensures that the unique EF context instance is obtained in the current thread.

 

→ DbSession: Implementation of the IDbSession Interface

I mainly did three things:
1. Submit all changes
2. Obtain the IXXXRepository types
3. Execute SQL statements

 

→ DbSessionFactory, implementing the IDbSessionFactory Interface

The implementation process ensures that the unique data layer access entry IDbSession instance is obtained in the current thread.

 

IBLL Layer

 

→ IBaseService is the basic interface of all IXXXService interfaces and provides generic implementation.

Its implementation avoids repeated parts of each IXXXService interface.

 

→ IProductService: Implementation of the Basic interface IBaseService <Product>

 

BLL Layer

 

→Baseservice is the base class of all XXXService and provides generic implementation.

Its implementation avoids the repetition of each XXXService.
After the IDisposable interface is implemented, manual recovery can be implemented.

 

→ ProductService, derived from the BaseService <Product> base class.
Its behavior is restricted by implementing the IProductService interface.

 

The source code is here.

 

The series "MVC project practices, implementing SportsStore in a three-tier architecture" includes:

MVC project practice, realize SportsStore under the three-tier architecture, view the three-tier architecture MVC project practice from the class diagram, implement SportsStore-01 under the three-tier architecture, EF Code First modeling, DAL layer and other MVC project practices, under the three-tier architecture to achieve SportsStore-02, DbSession layer, BLL layer MVC project practice, in the three-tier architecture to achieve SportsStore-03, Ninject controller factory MVC project practice, in the three-tier architecture to achieve SportsStore-04, implementation of paging MVC project practice, in the three-layer architecture to achieve SportsStore-05, to achieve the navigation MVC project practice, in the three-layer architecture to achieve SportsStore-06, to achieve the shopping cart MVC project practice, in the three-layer architecture to achieve SportsStore-07, implementation of order to submit MVC project practice, in the three-tier architecture to achieve SportsStore-08, deployment to IIS server MVC project practice, in the three-tier architecture to achieve SportsStore-09, ASP. net mvc calls ASP. NET Web API query service

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.