Esempio n. 1
0
        /// <summary>
        /// 查询的数据
        /// </summary>
        /// <param name="id">额外的参数</param>
        /// <param name="page">页码</param>
        /// <param name="rows">每页显示的行数</param>
        /// <param name="order">排序字段</param>
        /// <param name="sort">升序asc(默认)还是降序desc</param>
        /// <param name="search">查询条件</param>
        /// <param name="total">结果集的总数</param>
        /// <returns>结果集</returns>
        public List <Department> GetByParam(string id, int page, int rows, string order, string sort, string search, ref int total)
        {
            IQueryable <Department> queryData = repository.DaoChuData(db, order, sort, search);

            total = queryData.Count();
            if (total > 0)
            {
                if (page <= 1)
                {
                    queryData = queryData.Take(rows);
                }
                else
                {
                    queryData = queryData.Skip((page - 1) * rows).Take(rows);
                }

                foreach (var item in queryData)
                {
                    if (item.parentid != null && item.Department2 != null)
                    {
                        item.parentidOld = item.Department2.name.GetString();        //
                    }
                }
            }
            return(queryData.ToList());
        }