public IPagedList <MailHoldLogsExt> GetMailHoldLogsList(MailHoldLogsParam param) { var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); Expression <Func <MailHoldLog, bool> > filter = p => true; IQueryable <MailHoldLogsExt> query = null; if (param.TrackNumbers != null && param.TrackNumbers.Any()) { query = from w in ctx.WayBillInfos join c in ctx.Countries on w.CountryCode equals c.CountryCode join t in ctx.MailPostBagInfos on w.OutStorageID equals t.OutStorageID join m in ctx.MailHoldLogs on w.TrackingNumber equals m.TrackingNumber into wt from e in wt.DefaultIfEmpty() where param.TrackNumbers.Contains(w.TrackingNumber) select new MailHoldLogsExt { TrackNumber = w.TrackingNumber, PostBagNumber = t.PostBagNumber, HoldOn = e.HoldOn, HoldBy = e.HoldBy, Weight = w.Weight, CountryName = c.ChineseName, }; } else { filter = filter.AndIf(r => r.HoldOn >= param.StartTime, param.StartTime.HasValue) .AndIf(r => r.HoldOn < param.EndTime, param.EndTime.HasValue); query = from w in ctx.WayBillInfos join c in ctx.Countries on w.CountryCode equals c.CountryCode join t in ctx.MailPostBagInfos on w.OutStorageID equals t.OutStorageID join m in ctx.MailHoldLogs.Where(filter) on w.TrackingNumber equals m.TrackingNumber select new MailHoldLogsExt { TrackNumber = w.TrackingNumber, PostBagNumber = t.PostBagNumber, HoldOn = m.HoldOn, HoldBy = m.HoldBy, Weight = w.Weight, CountryName = c.ChineseName, }; } return(query.OrderByDescending(p => p.HoldOn).ToPagedList(param.Page, param.PageSize)); }
public IPagedList <MailHoldLogsExt> GetMailHoldLogsList(MailHoldLogsParam param) { return(_mailPostBagInfoRepository.GetMailHoldLogsList(param)); }