Пример #1
0
        private void FrmNormalView_Load(object sender, EventArgs e)
        {
            IGetAttribute attri = _object as IGetAttribute;

            if (attri != null)
            {
                this.dgvNormal.DataSource = NameAliasValue.ToDataTable(attri.GetAttributes());
            }
            ICreateSql creatsql = _object as ICreateSql;

            if (creatsql != null)
            {
                CreateSqlDelegate action = MyDbHelper.GetCreateSqlFunction(creatsql, _dbClass.GetClassDbType());
                if (action != null)
                {
                    List <CreateSqlObject> csos = action(_dbClass.GetCurrentTableSpaceName());
                    tbSql.Text = CreateSqlObject.ToCollectionSqls(csos);
                }
            }
        }
Пример #2
0
 public static DataTable ToDataTableX(IGetAttribute[] attris)
 {
     DataTable dt = new DataTable();
     if (attris.Length > 0)
     {
         List<NameAliasValue> navs = attris[0].GetAttributes();
         foreach (NameAliasValue item in navs)
         {
             dt.Columns.Add(new DataColumn(item.AliasName));
         }
         foreach (IGetAttribute item in attris)
         {
             DataRow dr = dt.NewRow();
             navs = item.GetAttributes();
             List<object> vals = new List<object>();
             foreach (NameAliasValue nv in navs)
             {
                 vals.Add(nv.Value);
             }
             dr.ItemArray = vals.ToArray();
             dt.Rows.Add(dr);
         }
     }
     return dt;
 }