C# 操作 XML 資料庫類型、Oracle XMLType

來源:互聯網
上載者:User

xml 類型很久就有了一直沒有關注,有時間正好看看;

這次學習要做的事情

1、設計一個C# 類來產生 XML Schema (XML 結構描述)

先設計類,然後由類產生表可能是有很多人蒙昧以求的;正好和 ORM 相反

最主要的 XML 結構描述可以用來約束資料庫中的;XML 的有效性

2、基於上一步的XML Schema我們建立一個資料表、並包含這個和上邊 C# 類對應的的 XML 類型;

3、插入一些資料;

4、改變 C# 的類重建 Schema在更新資料庫中的 Schema

這步假設業務變更看看,更改如何進行,是否方便等

5、用 C# 寫一個網頁,顯示這些資料;

6、階段性總結

好開始:

一、設計一個C# 類來產生 XML Schema類代碼:

類如下

namespace Model{    /// <summary>    /// 電話    /// </summary>    public class Phone    {        string _code;        /// <summary>        /// 電話號        /// </summary>        public string Code        {            get { return _code; }            set { _code = value; }        }        PhoneType _type;        public PhoneType Type        {            get { return _type; }            set { _type = value; }        }    }    /// <summary>    /// 電話類型    /// </summary>    public enum PhoneType    {        [XmlEnum(Name = "未知")] //XML 序列化用的名稱        Unknown,        [XmlEnum(Name = "移動")]        Mobile,        [XmlEnum(Name = "固定")]        Fixed,    }    /// <summary>    /// 電話集合    /// </summary>    [XmlRoot("Phones")]    public class Phones : List<Phone>    {        public void Add(string code, PhoneType type)        {            base.Add(new Phone() { Code = code, Type = type });        }    }}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.