Ejemplo n.º 1
0
        /// <summary>
        /// 分页获取实体列表。建议:如需使用Include和ThenInclude请重载此方法。
        /// </summary>
        public virtual IEnumerable <T> GetByPagination(Expression <Func <T, bool> > @where, int pageSize, int pageIndex, bool asc = true, params Func <T, object>[] @orderby)
        {
            var filter = DbContext.Get(where);

            if (orderby != null)
            {
                foreach (var func in orderby)
                {
                    filter = asc ? filter.OrderBy(func).AsQueryable() : filter.OrderByDescending(func).AsQueryable();
                }
            }
            return(filter.Skip(pageSize * (pageIndex - 1)).Take(pageSize));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取实体列表。建议:如需使用Include和ThenInclude请重载此方法。
 /// </summary>
 public virtual IList <T> Get(Expression <Func <T, bool> > @where = null)
 {
     return(DbContext.Get(where).ToList());
 }