跳到内容

ASP.NET/数据访问层和业务逻辑层

来自维基教科书,开放的书籍,开放的世界

DAL (数据访问层) & BLL (业务逻辑层)

[编辑 | 编辑源代码]

数据集

[编辑 | 编辑源代码]

添加新项: 数据集 打开数据库查看器,将数据库表拖放到数据集查看器中。

从数据集查看器中,您可以右键单击表格,添加新的查询并使用向导根据标准 SQL 配置它们。

BLL (业务逻辑层)

[编辑 | 编辑源代码]

添加新项: 类命名约定是在类名后添加 BLL,例如“CustomersBLL”。

Imports OrderingSystemDSTableAdapters

<System.ComponentModel.DataObject()> _
Public Class CustomersBLL

    Private _customersAdapater As CustomersTableAdapter = Nothing
    Protected ReadOnly Property CustomersAdapater() As CustomersTableAdapter
        Get
            If _customersAdapater Is Nothing Then
                _customersAdapater = New CustomersTableAdapter()
            End If
            Return _customersAdapater 
        End Get
    End Property

    <System.ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Select, True)> _
    Public Function getCustomer() As OrderingSystemDS.CustomersDataTable
        Return CustomersAdapater.GetCustomers()
    End Function

    <System.ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Select, False)> _
    Public Function getCustomerByCustomerID(ByVal CustomerID As Integer) As OrderingSystemDS.CustomersDataTable
        Return CustomersAdapater.GetCustomerByCustomerID(CustomerID)
    End Function

End Class
华夏公益教科书