ASP.NET-動軟程式碼生成器的使用
阿新 • • 發佈:2019-01-31
完成資料庫的設計之後,進入實體類的建立。實體類的建立可以藉助動軟程式碼生成器
例如我們要建立一個會員實體類MemberInfo的建立
首先開啟動軟程式碼生成器->選擇新增伺服器->連線伺服器->在資料庫中找到相對應的表
選中時候,選擇單表程式碼生成器:
進行相應的選擇之後,選擇生成程式碼:
專案中巧妙利用程式碼生成器可以極大減少工作量,提高工作效率。using System; namespace Maticsoft.Model { /// <summary> /// MemberInfo:實體類(屬性說明自動提取資料庫欄位的描述資訊) /// </summary> [Serializable] public partial class MemberInfo { public MemberInfo() {} #region Model private int _id; private int _cardid; private string _cardnumber; private string _name; private string _ic; private string _phone; private string _address; private DateTime _bdate; /// <summary> /// /// </summary> public int ID { set{ _id=value;} get{return _id;} } /// <summary> /// /// </summary> public int CardID { set{ _cardid=value;} get{return _cardid;} } /// <summary> /// /// </summary> public string CardNumber { set{ _cardnumber=value;} get{return _cardnumber;} } /// <summary> /// /// </summary> public string Name { set{ _name=value;} get{return _name;} } /// <summary> /// /// </summary> public string IC { set{ _ic=value;} get{return _ic;} } /// <summary> /// /// </summary> public string Phone { set{ _phone=value;} get{return _phone;} } /// <summary> /// /// </summary> public string Address { set{ _address=value;} get{return _address;} } /// <summary> /// /// </summary> public DateTime BDate { set{ _bdate=value;} get{return _bdate;} } #endregion Model } }