Beispiel #1
0
        /// <summary>
        /// 获取符合查询条件的前几行数据
        /// </summary>
        public List <Demo.MySQLModelQuery.Model.SysUserModel> GetList(int top, Demo.MySQLModelQuery.Model.SysUserQueryModel query, string filedOrder)
        {
            // 从查询条件获取SQL条件语句
            string strWhere = ConditionToSql.ToMySqlText(query.Condition);

            MySqlParameter[] paras = ConditionToSql.ToMySqlParas(query.Condition);

            // 构造SQL查询语句
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ");
            strSql.Append(" * ");
            strSql.Append(" FROM `sysuser` ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            if (top > 0)
            {
                strSql.Append(" limit 0," + top.ToString());
            }

            // 执行查询
            DataSet ds = MySQLHelper.Query(strSql.ToString(), paras);

            // 转换查询结果为List<T>,并返回
            return(DataTableToList(ds.Tables[0]));
        }
Beispiel #2
0
        /// <summary>
        /// 获取符合查询条件的全部记录数
        /// </summary>
        public int InfoCount(Demo.MySQLModelQuery.Model.SysUserQueryModel query)
        {
            // 从查询条件获取SQL条件语句
            string strWhere = ConditionToSql.ToMySqlText(query.Condition);

            MySqlParameter[] paras = ConditionToSql.ToMySqlParas(query.Condition);

            return(InfoCount(strWhere, paras));
        }
Beispiel #3
0
        /// <summary>
        /// 获取符合查询条件的分页数据
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <param name="page">分页条件</param>
        /// <returns></returns>
        public List <Demo.MySQLModelQuery.Model.SysUserModel> GetList(Demo.MySQLModelQuery.Model.SysUserQueryModel query, string sortFiled, ref PageInfo page)
        {
            //if(string.IsNullOrEmpty(sortFiled)){
            //	sortFiled="AddTime DESC";
            //}

            // 从查询条件获取SQL条件语句
            string strWhere = ConditionToSql.ToMySqlText(query.Condition);

            MySqlParameter[] paras = ConditionToSql.ToMySqlParas(query.Condition);

            // 总记录数
            page.RecordCount = InfoCount(strWhere, paras);

            // 分页数据
            string  strSQL = MySQLPageQueryHelper.GetPageSQL(page.CurrentPage, page.PageSize, strWhere, sortFiled, "sysuser");
            DataSet ds     = MySQLHelper.Query(strSQL, paras);

            return(DataTableToList(ds.Tables[0]));
        }