不好意思啊,让大家久等了,第一次写这种文章,可能没有开心那么专业,废话少说,我们开始:
1.结构概述
Duwamish 7.0 结构分为四个逻辑层:
Web 层
Web 层为客户端提供对应用程序的访问。这一层是作为 Duwamish.sln 解决方案文件中的 Web 项目实现的。Web 层由 ASP.NET Web 窗体和代码隐藏文件组成。Web 窗体只是用 HTML 提供用户操作,而代码隐藏文件实现各种控件的事件处理。
业务外观层
业务外观层为 Web 层提供处理帐户、类别浏览和购书的界面。这一层是作为 Duwamish.sln 解决方案文件中的 BusinessFacade 项目实现的。业务外观层用作隔离层,它将用户界面与各种业务功能的实现隔离开来。除了低级系统和支持功能之外,对数据库服务器的所有调用都是通过此程序集进行的。
业务规则层
业务规则层是作为 Duwamish.sln 解决方案文件中的 BusinessRules 项目实现的,它包含各种业务规则和逻辑的实现。业务规则完成如客户帐户和书籍订单的验证这样的任务。
数据访问层
数据访问层为业务规则层提供数据服务。这一层是作为 Duwamish.sln 解决方案文件中的 DataAccess 项目实现的。
在这里,对于Duwamish 7.0的分布式结构我就不再罗嗦了,MSDN写的绝对比我好..
下面就从数据访问层开始解剖,我单独提出Customer这一段进行程序讲解:
1.CustomerData.cs(数据层)
Code:
//----------------------------------------------------------------
// Copyright (C) 2000-2001 Microsoft Corporation
// All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation. See these other
// materials for detailed information regarding Microsoft code samples.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
//----------------------------------------------------------------
namespace Duwamish7.Common.Data
{
using System;
using System.Data;
using System.Runtime.Serialization;
/// <summary>
/// A custom serializable dataset containing customer information.
/// <remarks>
/// This class is used to define the shape of CustomerData.
/// </remarks>
/// <remarks>
/// The serializale constructor allows objects of type CustomerData to be remoted.
/// </remarks>
/// </summary>
[SerializableAttribute]
public class CustomerData : DataSet
{
//
//Customer constants
//
/// <value>The constant used for Customers table. </value>
public const String CUSTOMERS_TABLE = "Customers";
/// <value>The constant used for Email field in the Customers table. </value>
public const String EMAIL_FIELD = "Email";
/// <value>The constant used for Name field in the Customers table. </value>
public const String NAME_FIELD = "Name";
/// <value>The constant used for Address field in the Customers table. </value>
public const String ADDRESS_FIELD = "Address";