/*********************************************************************** * Project: baifenBinfa * ProjectName: 百分兵法管理系统 * Web: http://chuanyin.com * Author: * Email: * CreateTime: 202403/02 * Description: 暂无 ***********************************************************************/ using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Threading.Tasks; using CoreCms.Net.Caching.Manual; using CoreCms.Net.Configuration; using CoreCms.Net.Model.Entities; using CoreCms.Net.IRepository; using CoreCms.Net.IRepository.UnitOfWork; using CoreCms.Net.Model.ViewModels.Basics; using CoreCms.Net.Model.ViewModels.UI; using SqlSugar; namespace CoreCms.Net.Repository { /// /// 库存操作详情表 接口实现 /// public class CoreCmsStockLogRepository : BaseRepository, ICoreCmsStockLogRepository { public CoreCmsStockLogRepository(IUnitOfWork unitOfWork) : base(unitOfWork) { } #region 重写根据条件查询分页数据 /// /// 重写根据条件查询分页数据 /// /// 判断集合 /// 排序方式 /// 当前页面索引 /// 分布大小 /// /// 是否使用WITH(NOLOCK) /// public async Task> QueryPageAsync(Expression> predicate, Expression> orderByExpression, OrderByType orderByType, int pageIndex = 1, int pageSize = 20, bool blUseNoLock = false) { RefAsync totalCount = 0; List page; if (blUseNoLock) { page = await DbClient.Queryable((p, stock) => new JoinQueryInfos(JoinType.Left, p.stockId == stock.id)) .Select((p, stock) => new CoreCmsStockLog { id = p.id, stockId = p.stockId, productId = p.productId, goodsId = p.goodsId, nums = p.nums, sn = p.sn, bn = p.bn, goodsName = p.goodsName, spesDesc = p.spesDesc, type = stock.type, manager = stock.manager, memo = stock.memo, createTime = stock.createTime }).With(SqlWith.NoLock) .MergeTable() .OrderByIF(orderByExpression != null, orderByExpression, orderByType) .WhereIF(predicate != null, predicate) .ToPageListAsync(pageIndex, pageSize, totalCount); } else { page = await DbClient.Queryable((p, stock) => new JoinQueryInfos(JoinType.Left, p.stockId == stock.id)) .Select((p, stock) => new CoreCmsStockLog { id = p.id, stockId = p.stockId, productId = p.productId, goodsId = p.goodsId, nums = p.nums, sn = p.sn, bn = p.bn, goodsName = p.goodsName, spesDesc = p.spesDesc, type = stock.type, manager = stock.manager, memo = stock.memo, createTime = stock.createTime }) .MergeTable() .OrderByIF(orderByExpression != null, orderByExpression, orderByType) .WhereIF(predicate != null, predicate) .ToPageListAsync(pageIndex, pageSize, totalCount); } var list = new PageList(page, pageIndex, pageSize, totalCount); return list; } #endregion } }