/// <summary> /// 判断表字段集合中是否存在某字段 /// </summary> /// <param name="index"></param> /// <param name="list"></param> /// <returns></returns> public bool containsInList(TableCharacter index, List <TableCharacter> list) { bool contains = false; foreach (var temp in list) { if (temp.Field == index.Field) { contains = true; break; } } return(contains); }
/// <summary> /// 获取表的字段和属性值 /// </summary> /// <param name="tableName"></param> /// <returns></returns> public List <TableCharacter> GetTableCharacters(string tableName) { List <TableCharacter> lstTableChar = new List <TableCharacter>(); string sql = string.Format("desc {0}", tableName); DataTable dt = MySqlHelp.ExecuteSql(MySqlHelp.ConnectionStr, sql); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { TableCharacter temp = new TableCharacter(); temp.Field = dr["Field"].ToString(); temp.Type = dr["Type"].ToString(); lstTableChar.Add(temp); } } return(lstTableChar); }