public static ExpressionStarter <ReturnOrder> GetPredicate(this QReturnOrder query) { var predicate = PredicateBuilder.New <ReturnOrder>(true); return(predicate); }
public async Task <PagedResult <PTCStore.RanderModels.RReturnOrder> > ReturnOrders(PTCStore.QueryModels.QReturnOrder query, int page, int pageSize = 10) { var rs = _context.ReturnOrders.Where(query.GetPredicate()).Select(o => new RReturnOrder { ApplyNumber = o.ApplyNumber, ReturnOrderId = o.ReturnOrderId, ReturnDate = o.ReturnDate, CustomerName = o.Customer.Name, CustomerConnecter = o.Customer.Connecter, OrgPrice = o.ReturnOrderSubs.Select(x => x.Barcode.Purchase.PurchasePrice / (x.Barcode.Purchase.Formate.DoTimes ? x.Barcode.Purchase.Formate.SetCount : 1)).Sum(), ReturnPrice = o.ReturnOrderSubs.Select(r => r.ReturnPrice).Sum(), SalePrice = o.ReturnOrderSubs.Select(r => r.SalePrice).Sum(), ItemCount = o.ReturnOrderSubs.Count(), }); return(await rs.GetPagedAsync(pageSize, page, query.Sort)); }