日期:2014-05-20 浏览次数:20824 次
public static DataTable CopyToDataTable<T>( IEnumerable<T> array) { var ret = new DataTable(); foreach (PropertyDescriptor dp in TypeDescriptor.GetProperties(typeof(T))) // if (!dp.IsReadOnly) ret.Columns.Add(dp.Name, dp.PropertyType); foreach (T item in array) { var Row = ret.NewRow(); foreach (PropertyDescriptor dp in TypeDescriptor.GetProperties(typeof(T))) // if (!dp.IsReadOnly) Row[dp.Name] = dp.GetValue(item); ret.Rows.Add(Row); } return ret; }
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] public long id { get { return this._id; } set { if ((this._id != value)) { this.OnidChanging(value); this.SendPropertyChanging(); this._id = value; this.SendPropertyChanged("id"); this.OnidChanged(); } } } [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_age", DbType="BigInt")] public System.Nullable<long> age { get { return this._age; } set { if ((this._age != value)) { this.OnageChanging(value); this.SendPropertyChanging(); this._age = value; this.SendPropertyChanged("age"); this.OnageChanged(); } } }