Example #1
0
        public GroupInfo GetGroupInfoById(IDbCommand icmd, Guid id)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            string sql = @"select id,name,description,updatetime,status from t_group_info
                            where id = '{0}'";

            cmd.CommandText = string.Format(sql, id);
            GroupInfo info = null;
            DataTable dt   = new DataTable();

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                info = new GroupInfo();
                info.AllParse(dt.Rows[0]);
            }
            return(info);
        }
Example #2
0
        public List <GroupInfo> GetGroupInfoPageList(IDbCommand icmd, string fileds, string whereCondition, string orderby, string limit)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(fileds))
            {
                sb.AppendFormat("select {0} from t_group_info ", fileds);
            }
            if (!string.IsNullOrEmpty(whereCondition))
            {
                sb.AppendFormat("{0} ", whereCondition);
            }
            sb.AppendFormat("{0} ", orderby);
            sb.AppendFormat("{0}", limit);
            cmd.CommandText = sb.ToString();
            List <GroupInfo> list = new List <GroupInfo>();
            DataTable        dt   = new DataTable();

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                GroupInfo info = null;
                foreach (DataRow dr in dt.Rows)
                {
                    info = new GroupInfo();
                    info.AllParse(dr);
                    if (null != info)
                    {
                        list.Add(info);
                    }
                }
            }
            return(list);
        }