程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> ASP.NET >> 關於ASP.NET >> 數據庫組件 Hxj.Data (一)(介紹篇)

數據庫組件 Hxj.Data (一)(介紹篇)

編輯:關於ASP.NET

Hxj.Data經過幾個月的開發,終於發布了一個版本,並同時發布實體生成工具。在開發過程參考了多個ORM框架,特別是NBear,MySoft等。 吸取了他們的一些精華,加入自己的新思想。

目前支持Sql2000\2005,MsAccess,Oracle三個數據庫,如有需要可再擴展。

數據庫實體生成的代碼Northwind數據庫中Products表:

//------------------------------------------------------------------------------
// <auto-generated>
//   此代碼由工具生成。
//   運行時版本:2.0.50727.4200
//
//   對此文件的更改可能會導致不正確的行為,並且如果
//   重新生成代碼,這些更改將會丟失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Data;
using System.Data.Common;
using Hxj.Data;
using Hxj.Data.Common;
namespace Hxj.Model
{
   /// <summary>
   /// 實體類Products 。(屬性說明自動提取數據庫字段的描述信息)
   /// </summary>
   [Serializable]
   public class Products : Entity
   {
     public Products():base("Products") {}
     #region Model
     private int _ProductID;
     private string _ProductName;
     private int? _SupplierID;
     private int? _CategoryID;
     private string _QuantityPerUnit;
     private decimal? _UnitPrice;
     private int? _UnitsInStock;
     private int? _UnitsOnOrder;
     private int? _ReorderLevel;
     private bool _Discontinued;
     /// <summary>
     ///
     /// </summary>
     public int ProductID
     {
       get{ return _ProductID; }
       set
       {
         this.OnPropertyValueChange(_.ProductID,_ProductID,value);
         this._ProductID=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public string ProductName
     {
       get{ return _ProductName; }
       set
       {
         this.OnPropertyValueChange(_.ProductName,_ProductName,value);
         this._ProductName=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public int? SupplierID
     {
       get{ return _SupplierID; }
       set
       {
         this.OnPropertyValueChange(_.SupplierID,_SupplierID,value);
         this._SupplierID=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public int? CategoryID
     {
       get{ return _CategoryID; }
       set
       {
         this.OnPropertyValueChange(_.CategoryID,_CategoryID,value);
         this._CategoryID=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public string QuantityPerUnit
     {
       get{ return _QuantityPerUnit; }
       set
       {
         this.OnPropertyValueChange(_.QuantityPerUnit,_QuantityPerUnit,value);
         this._QuantityPerUnit=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public decimal? UnitPrice
     {
       get{ return _UnitPrice; }
       set
       {
         this.OnPropertyValueChange(_.UnitPrice,_UnitPrice,value);
         this._UnitPrice=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public int? UnitsInStock
     {
       get{ return _UnitsInStock; }
       set
       {
         this.OnPropertyValueChange(_.UnitsInStock,_UnitsInStock,value);
         this._UnitsInStock=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public int? UnitsOnOrder
     {
       get{ return _UnitsOnOrder; }
       set
       {
         this.OnPropertyValueChange(_.UnitsOnOrder,_UnitsOnOrder,value);
         this._UnitsOnOrder=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public int? ReorderLevel
     {
       get{ return _ReorderLevel; }
       set
       {
         this.OnPropertyValueChange(_.ReorderLevel,_ReorderLevel,value);
         this._ReorderLevel=value;
       }
     }
     /// <summary>
     ///
     /// </summary>
     public bool DiscontinueD
     {
       get{ return _Discontinued; }
       set
       {
         this.OnPropertyValueChange(_.Discontinued,_Discontinued,value);
         this._Discontinued=value;
       }
     }
     #endregion 
     #region MethoD
     /// <summary>
     /// 獲取實體中的標識列 
     /// </summary>
     public override Field GetIdentityField()
     {
       return _.ProductID;
     }
     /// <summary>
     /// 獲取實體中的主鍵列 
     /// </summary>
     public override Field[] GetPrimaryKeyFields()
     {
       return new Field[] {
         _.ProductID};
     }
     /// <summary>
     /// 獲取列信息 
     /// </summary>
     public override Field[] GetFields()
     {
       return new Field[] {
         _.ProductID,
         _.ProductName,
         _.SupplierID,
         _.CategoryID,
         _.QuantityPerUnit,
         _.UnitPrice,
         _.UnitsInStock,
         _.UnitsOnOrder,
         _.ReorderLevel,
         _.Discontinued};
     }
     /// <summary>
     /// 獲取值信息 
     /// </summary>
     public override object[] GetValues()
     {
       return new object[] {
         this._ProductID,
         this._ProductName,
         this._SupplierID,
         this._CategoryID,
         this._QuantityPerUnit,
         this._UnitPrice,
         this._UnitsInStock,
         this._UnitsOnOrder,
         this._ReorderLevel,
         this._Discontinued};
     }
     /// <summary>
     /// 給當前實體賦值 
     /// </summary>
     public override void SetPropertyValues(IDataReader reader)
     {
       this._ProductID = DataUtils.ConvertValue<int>(reader["ProductID"]);
       this._ProductName = DataUtils.ConvertValue<string>(reader["ProductName"]);
       this._SupplierID = DataUtils.ConvertValue<int?>(reader["SupplierID"]);
       this._CategoryID = DataUtils.ConvertValue<int?>(reader["CategoryID"]);
       this._QuantityPerUnit = DataUtils.ConvertValue<string>(reader["QuantityPerUnit"]);
       this._UnitPrice = DataUtils.ConvertValue<decimal?>(reader["UnitPrice"]);
       this._UnitsInStock = DataUtils.ConvertValue<int?>(reader["UnitsInStock"]);
       this._UnitsOnOrder = DataUtils.ConvertValue<int?>(reader["UnitsOnOrder"]);
       this._ReorderLevel = DataUtils.ConvertValue<int?>(reader["ReorderLevel"]);
       this._Discontinued = DataUtils.ConvertValue<bool>(reader["Discontinued"]);
     }
     /// <summary>
     /// 給當前實體賦值 
     /// </summary>
     public override void SetPropertyValues(DataRow row)
     {
       this._ProductID = DataUtils.ConvertValue<int>(row["ProductID"]);
       this._ProductName = DataUtils.ConvertValue<string>(row["ProductName"]);
       this._SupplierID = DataUtils.ConvertValue<int?>(row["SupplierID"]);
       this._CategoryID = DataUtils.ConvertValue<int?>(row["CategoryID"]);
       this._QuantityPerUnit = DataUtils.ConvertValue<string>(row["QuantityPerUnit"]);
       this._UnitPrice = DataUtils.ConvertValue<decimal?>(row["UnitPrice"]);
       this._UnitsInStock = DataUtils.ConvertValue<int?>(row["UnitsInStock"]);
       this._UnitsOnOrder = DataUtils.ConvertValue<int?>(row["UnitsOnOrder"]);
       this._ReorderLevel = DataUtils.ConvertValue<int?>(row["ReorderLevel"]);
       this._Discontinued = DataUtils.ConvertValue<bool>(row["Discontinued"]);
     }
     #endregion 
     #region _FielD
     /// <summary>
     /// 字段信息 
     /// </summary>
     public class _
     {
       public readonly static Field All = new Field("*","Products");
       public readonly static Field ProductID = new Field("ProductID","Products","ProductID");
       public readonly static Field ProductName = new Field("ProductName","Products","ProductName");
       public readonly static Field SupplierID = new Field("SupplierID","Products","SupplierID");
       public readonly static Field CategoryID = new Field("CategoryID","Products","CategoryID");
       public readonly static Field QuantityPerUnit = new Field ("QuantityPerUnit","Products","QuantityPerUnit");
       public readonly static Field UnitPrice = new Field("UnitPrice","Products","UnitPrice");
       public readonly static Field UnitsInStock = new Field("UnitsInStock","Products","UnitsInStock");
       public readonly static Field UnitsOnOrder = new Field("UnitsOnOrder","Products","UnitsOnOrder");
       public readonly static Field ReorderLevel = new Field("ReorderLevel","Products","ReorderLevel");
       public readonly static Field Discontinued = new Field("Discontinued","Products","Discontinued");
     }
     #endregion 
   }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved