Ejemplo n.º 1
0
        private static string buildQueryCmd()
        {
            string rtnString = null;

            for (int index = 0; index < MapList.Count; index++)
            {
                Attr2FieldMap map = MapList[index];
                if (rtnString == null)
                {
                    rtnString = map.Field;
                    continue;
                }

                rtnString = rtnString + "," + map.Field;
            }

            return(String.Format("select {0} from {1} where 1=1;", rtnString, _tableName));
        }
Ejemplo n.º 2
0
        public static List <SUrlAttribute> FetchObject(MysqlDBHelper helper)
        {
            initMap();

            List <SUrlAttribute> rtnResult = new List <SUrlAttribute>();

            String       cmdString = buildQueryCmd();
            MySqlCommand cmd       = new MySqlCommand(cmdString, helper.DbConnector);
            //查询结果读取器
            MySqlDataReader reader = null;

            try
            {
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    SUrlAttribute cfg = new SUrlAttribute();

                    for (int index = 0; index < MapList.Count; index++)
                    {
                        Attr2FieldMap map = MapList[index];

                        Attr2FieldMap.setValue(cfg, reader[index], map.Attrbute);
                    }

                    rtnResult.Add(cfg);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }


            return(rtnResult);
        }