Books.Service/BookService.cs

(完整代码) 1KB

using Books.Service.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Books.Service
{
    public class BookService
    {
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pageSize">一页多少条</param>
        /// <param name="pageIndex">第几页</param>
        /// <param name="total">共多少条</param>
        /// <param name="where">筛选条件可多条</param>
        /// <returns></returns>
        public List<BookEntity> GetPageDate(int pageSize, int pageIndex, out int total,Expression<Func<BookEntity,bool>> where)
        {
            BaseService<BookEntity> bs = new BaseService<BookEntity>();
            var list = bs.GetAll();
            IQueryable<BookEntity> li = null ;
           
             li=list.Where(where);
            total = li.Count();
            return li.OrderBy(e=>e.CreateDateTime).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList(); 
        }
        public BookEntity GetBook(int id)
        {
            BaseService<BookEntity> bs = new BaseService<BookEntity>();
            return bs.GetId(id);
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。