コード例 #1
0
ファイル: SUrl.cs プロジェクト: caojiaju-2017/Spider
        public static List <SUrl> FetchObject(MysqlDBHelper helper)
        {
            initMap();

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

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

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

                    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);
        }