Based on. NET platform's layered architecture combat (10)-The realization of business logic layer

Source: Internet
Author: User
Tags config requires administrator password

In this article, a Nguestbook business logic layer is implemented.

In the practical application, the business logic layer is very important, he carries the whole system the core part, is also the customer most attention part. This part of the implementation, usually requires the cooperation of technical experts and field experts. Of course, in the demo of this article series, because of the simplicity of the business logic, it may not be obvious to see here.

In the business logic layer implementation of this article, the business logic layer mainly undertakes the following responsibilities:

1. Encapsulation of different data access layers. This allows the presentation layer to be indifferent to the specific data access layer.

2. The filling and conversion of business logic data. such as encryption of the administrator password.

3. The realization of the core business. Many of the business logic here have only one line of code, that is, a business logic method corresponds exactly to a data access method, but there are several methods of data access to achieve the business. The ChangePassword method in Adminbll, for example, invokes the Admindal GetByID and update two methods. In addition, although many methods call only one data access method, it can be seen from the naming to see the difference between the two. such as the Getbynameandpassword in Admindal, the name is clearly from the database point of view-refers to the specified name and password two fields of the value of the corresponding information, as the business meaning of doing so it does not need to know. In Adminbll, the way to call it is login, which is from a business point of view-that is, the method is an admin login.

The following step-by-step implementation of the business Logic layer:

1. Establishment of the project

In this architecture, the business logic layer can be replaced. And the business logic layer is not directly coupled to the presentation layer, but is realized by the dependency injection mechanism. So, instead of naming this business logic layer directly as BLL, we're creating a new project called SIMPLEBLL that places the relevant code for our business logic layer.

2. Configuring Dependency Injection

The business logic layer loads the appropriate data access layer through the reflection factory, which requires the configuration of the data access layer that needs to be used in the web.config. Open Web.config, locate the "DAL" item under the appsettings node and give the value of the data Access layer project name that we want to use, for example: To use Nbeardal, this should be the case:

<add key= "DAL" value= "Nbeardal"/>

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.