国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

深度剖析Duwamish 7.0 (1--數(shù)據(jù)結(jié)構(gòu))

2024-07-21 02:25:27
字體:
供稿:網(wǎng)友
不好意思啊,讓大家久等了,第一次寫這種文章,可能沒有開心那么專業(yè),廢話少說,我們開始:

1.結(jié)構(gòu)概述
duwamish 7.0 結(jié)構(gòu)分為四個(gè)邏輯層:
web 層
web 層為客戶端提供對(duì)應(yīng)用程序的訪問。這一層是作為 duwamish.sln 解決方案文件中的 web 項(xiàng)目實(shí)現(xiàn)的。web 層由 asp.net web 窗體和代碼隱藏文件組成。web 窗體只是用 html 提供用戶操作,而代碼隱藏文件實(shí)現(xiàn)各種控件的事件處理。

業(yè)務(wù)外觀層
業(yè)務(wù)外觀層為 web 層提供處理帳戶、類別瀏覽和購書的界面。這一層是作為 duwamish.sln 解決方案文件中的 businessfacade 項(xiàng)目實(shí)現(xiàn)的。業(yè)務(wù)外觀層用作隔離層,它將用戶界面與各種業(yè)務(wù)功能的實(shí)現(xiàn)隔離開來。除了低級(jí)系統(tǒng)和支持功能之外,對(duì)數(shù)據(jù)庫服務(wù)器的所有調(diào)用都是通過此程序集進(jìn)行的。

業(yè)務(wù)規(guī)則層
業(yè)務(wù)規(guī)則層是作為 duwamish.sln 解決方案文件中的 businessrules 項(xiàng)目實(shí)現(xiàn)的,它包含各種業(yè)務(wù)規(guī)則和邏輯的實(shí)現(xiàn)。業(yè)務(wù)規(guī)則完成如客戶帳戶和書籍訂單的驗(yàn)證這樣的任務(wù)。

數(shù)據(jù)訪問層
數(shù)據(jù)訪問層為業(yè)務(wù)規(guī)則層提供數(shù)據(jù)服務(wù)。這一層是作為 duwamish.sln 解決方案文件中的 dataaccess 項(xiàng)目實(shí)現(xiàn)的。
        
在這里,對(duì)于duwamish 7.0的分布式結(jié)構(gòu)我就不再羅嗦了,msdn寫的絕對(duì)比我好..

下面就從數(shù)據(jù)訪問層開始解剖,我單獨(dú)提出customer這一段進(jìn)行程序講解:

1.customerdata.cs(數(shù)據(jù)層)
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";
        /// <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 an '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 on who is 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

大家可以看到,這里的customerdata類繼承與dataset,詳細(xì)定義字段名稱以及有可能產(chǎn)生的出錯(cuò)信息,
并同時(shí)繪制出一張空表格。
ok,這里的代碼非常簡(jiǎn)單,大家一看應(yīng)該就可以明白。代碼的技巧性非常強(qiáng),以后的數(shù)據(jù)訪問、交換、傳遞全部通過這里進(jìn)行。
私底下認(rèn)為,采用這種方法有利于團(tuán)隊(duì)協(xié)作,代碼編輯也很簡(jiǎn)單。
但是,微軟自己也說過dataset的效率沒有datareader高,而dataset的靈活性遠(yuǎn)遠(yuǎn)超過于datareader,真搞不懂ms在企業(yè)事例中為什么采用dataset,也許只是讓我們學(xué)習(xí)其中的思想吧。
過兩天再和大家談?wù)劻硪环N方法,采用datareader,效率高點(diǎn),但是代碼太難看,難懂:(
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 贡山| 桂平市| 凉山| 太和县| 双辽市| 东方市| 洞口县| 南乐县| 兰州市| 新民市| 胶州市| 双鸭山市| 阳朔县| 桦川县| 正镶白旗| 九龙县| 临桂县| 洛南县| 满洲里市| 二连浩特市| 台州市| 宁德市| 石景山区| 禹州市| 郯城县| 北碚区| 普兰县| 丁青县| 昭觉县| 西充县| 布拖县| 高邮市| 历史| 金昌市| 仪征市| 隆安县| 徐闻县| 盈江县| 佛冈县| 乌兰县| 昌图县|