ASP.net 2.0 Data manipulation creation business Logic Layer

Source: Internet
Author: User

Introduction

The data access layer, described in the first section of this tutorial, is a clear distinction between presentation logic and data access logic, as in the case of Layer, the following referred to as DAL. However, even if the DAL separates the details of data access from the presentation layer, it cannot handle any business rules. For example, we may not want the "category number" or "vendor number" of products in the product table that are marked "deactivated" to be updated; We may also need to apply some seniority rules, such as we don't want to be managed by someone who is less than our own qualifications. Another common scenario is authorization, for example, that only users with special privileges can delete a product or change the unit price.

We can actually think of the business Logic layer (Business Logic Layer, BLL) as a bridge between the data access layer and the presentation layer, and in this section we'll discuss how to integrate these business rules into a BLL. It should be explained that in a real-world application, BLL is implemented in the form of class libraries, but in order to simplify the structure of the project, in this tutorial we will implement BLL as a series of classes in the App_Code folder. The graph has always shown the structural relationship between the presentation layer, the BLL, and the DAL.

Figure one: BLL separates the presentation layer from the Dal and joins the business rules

First step: Create BLL Class

Our BLL consists of 4 classes, each of which corresponds to a TableAdapter in the DAL, which are read, inserted, modified, and deleted from their TableAdapter to apply the appropriate business rules.

To make a clearer distinction between dal and BLL classes, we created two subfolders in the App_Code folder, named Dal and BLL respectively. You just need to right-click the App_Code folder in Solution Explorer (Solution Explorer) and select New folder to create a new subfolder. After the two folders have been built, move the typed dataset (Typed DataSet) created in the first section to the Dal folder.

Then, create 4 class files in the BLL folder. Again, you just need to right-click the BLL folder in the Solution Explorer (Solution Explorer) and select New Item, and then select Class template in the pop-up dialog box to create a new class file. Each of these four files is named Productsbll, CATEGORIESBLL, SUPPLIERSBLL, and EMPLOYEESBLL.

Figure Two: Add 4 new classes to the BLL folder

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.