using HotelPms.Share.Util; using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace HotelPms.Data.Master; public partial class RoomTypeTable { /// /// 自動データテーブル生成 /// /// public DataTable ToDataTable() { DataTable dataTable = new DataTable(); dataTable.TableName = Name; PropertyInfo[] myInfo = typeof(RoomType).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo item in myInfo) { System.Diagnostics.Debug.WriteLine(item.Name); Attribute attribute = item.GetCustomAttribute(typeof(DebuggerNonUserCodeAttribute)); if (attribute == null) { continue; } dataTable.Columns.Add(item.Name, item.PropertyType); } //データ foreach (RoomType row in Rows) { DataRow dtRow = dataTable.NewRow(); row.ToDataRow(dtRow); dataTable.Rows.Add(dtRow); } return dataTable; } }