Depth Analysis Duwamish 7.0 (1--data structure)

Source: Internet
Author: User
Tags constant constructor serialization
Data | Structure Sorry ah, let everyone wait, the first time to write this article, may not be happy so professional, less nonsense, we began:

1. Structure overview
The Duwamish 7.0 structure is divided into four logical tiers:
Web Layer
The WEB layer provides access to the application to clients. This layer is implemented as a WEB project in the Duwamish.sln solution file. The Web layer consists of asp.net Web Forms and code-behind files. Web forms only provide user actions in HTML, and code-behind files implement event handling for various controls.

Business Facade Layer
The business Facade layer provides the WEB layer with an interface for processing accounts, category browsing, and buying books. This layer is implemented as a BusinessFacade project in the Duwamish.sln solution file. The business Facade layer is used as the isolation layer, separating the user interface from the implementation of various business functions. All calls to the database server are made through this assembly, in addition to low-level systems and support features.

Business Rules Layer
The business rules layer is implemented as a BusinessRules project in the Duwamish.sln solution file, which contains a variety of business rules and logic implementations. Business rules complete such tasks as customer accounts and the validation of book orders.

Data Access Layer
The data access layer provides data services for the business Rules layer. This layer is implemented as a DataAccess project in the Duwamish.sln solution file.

Here, for the distributed architecture of Duwamish 7.0, I'm no longer verbose, and MSDN is definitely better than me.

The following is from the data access layer to begin anatomy, I raised the customer this section of the program to explain:

1.customerdata.cs (Data layer)
Code:

//----------------------------------------------------------------
Copyright (C) 2000-2001 Microsoft Corporation
All rights reserved.
//
This source code was intended only as a supplement to Microsoft
Development Tools and/or on-line documentation. The other
Materials for detailed information regarding Microsoft code samples.
//
This CODE and information are 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 is 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 e-mail 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 ';
<value>the constant used for Country field in the Customers table. </value>
Public Const String Country_field = "COUNTRY";
<value>the constant used for Password field in the Customers table. </value>
Public Const String Password_field = "PASSWORD";
<value>the constant used for phonenumber field in the Customers table. </value>
Public Const String Phone_field = "PhoneNumber";
<value>the constant used for Fax field in the Customers table. </value>
Public Const String Fax_field = "FAX";
<value>the constant used for pkid field in the Customers table. </value>
Public Const String Pkid_field = "Pkid";
//
Error messages
//
<value>the constant used for row error when ' Email not Unique ' field in CustomerData. </value>
Public Const String Email_field_not_unique = ' EMAIL not UNIQUE ';
<value>the constant used for row error when ' Email Invalid Format ' field in CustomerData. </value>
Public Const String Email_field_invalid_format = "EMAIL INVALID FORMAT";
<value>the constant used for row error when there is a ' Invalid Field ' in CustomerData. </value>
Public Const String Invalid_field = "INVALID FIELD";
<value>the constant used for error when ' Invalid Fields ' exist in CustomerData. </value>
Public Const String Invalid_fields = "INVALID FIELDS";

<summary>
constructor to support serialization.
<remarks>constructor that supports serialization.</remarks>
<param name= "Info" >the SerializationInfo object to read from.</param>
<param name= "Context" >information to who's calling this method.</param>
</summary>
Public CustomerData (SerializationInfo info, StreamingContext context): Base (info, context)
{
}

<summary>
Constructor for CustomerData.
<remarks>initialize a CustomerData instance by building the table schema.</remarks>
</summary>
Public CustomerData ()
{
//
Create the tables in the dataset
//
Builddatatables ();
}

//----------------------------------------------------------------
Sub Builddatatables:
Creates the following datatables:customers
//----------------------------------------------------------------
private void Builddatatables ()
{
//
Create the Customers table
//
DataTable table = new DataTable (customers_table);
datacolumncollection columns = table. Columns;

DataColumn Column = columns. Add (Pkid_field, typeof (System.Int32));

Column.allowdbnull = false;
Column.autoincrement = true;

Columns. Add (Email_field, typeof (System.String));
Columns. Add (Password_field, typeof (System.String));
Columns. Add (Name_Field, typeof (System.String));
Columns. Add (Address_field, typeof (System.String)). Allowdbnull= false;
Columns. Add (Country_field, typeof (System.String)). Allowdbnull= false;
Columns. Add (Phone_field, typeof (System.String)). Allowdbnull= false;
Columns. Add (Fax_field, typeof (System.String));

This. Tables.add (table);
}

}//class CustomerData

}//namespace Duwamish7.Common.Data

As you can see, the CustomerData class inherits and datasets, detailing field names and possible error messages.
and draw an empty table at the same time.
OK, the code here is very simple, you can see it should be understood. The skill of the code is very strong, the later data accesses, exchanges, passes all through here.
In private, this approach facilitates teamwork, and code editing is simple.
However, Microsoft itself has said that the dataset is not DataReader efficiency, and dataset flexibility far more than DataReader, I really do not understand MS in the enterprise case why use dataset, perhaps just let us learn the idea of it.
We'll talk to you in two days. Another method, using DataReader, high efficiency, but the code is too ugly, difficult to understand: (

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.