public List <TrackingNumberExt> GetTrackingNumberExtList(TrackingNumberParam param) { Expression <Func <TrackingNumberInfo, bool> > filter = o => true; filter = filter.AndIf(o => o.ShippingMethodID == param.shippingMehtodId, param.shippingMehtodId.HasValue) .AndIf(o => o.Status == (short)TrackingNumberInfo.StatusEnum.Enable, true) .AndIf(o => o.CreatedNo >= param.StartTime, param.StartTime.HasValue) .AndIf(o => o.CreatedNo <= param.EndTime, param.EndTime.HasValue); var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); var list = (from tnInfo in ctx.TrackingNumberInfos.Where(filter) orderby tnInfo.CreatedNo descending select new TrackingNumberExt { TrackingNumberID = tnInfo.TrackingNumberID, ShippingMethodID = tnInfo.ShippingMethodID, ApplianceCountry = tnInfo.ApplianceCountry, Status = tnInfo.Status, Remarks = tnInfo.Remarks, NotUsed = ctx.TrackingNumberDetailInfos.Count(p => p.TrackingNumberID == tnInfo.TrackingNumberID && p.Status == (short)TrackingNumberDetailInfo.StatusEnum.NotUsed), Used = ctx.TrackingNumberDetailInfos.Count(p => p.TrackingNumberID == tnInfo.TrackingNumberID && p.Status == (short)TrackingNumberDetailInfo.StatusEnum.Used), CreatedNo = tnInfo.CreatedNo }); return(list.ToList()); }
/// <summary> /// 跟踪号管理页面查询 /// </summary> /// <param name="param"></param> /// <returns></returns> public SelectTrackingNumberExt GetTrackingNumberDetails(TrackingNumberParam param) { SelectTrackingNumberExt model = new SelectTrackingNumberExt(); var ctx = this.UnitOfWork as LMS_DbContext; Check.Argument.IsNotNull(ctx, "数据库对象"); var list = (from tnInfo in ctx.TrackingNumberInfos .WhereIf(p => p.ShippingMethodID == param.shippingMehtodId, param.shippingMehtodId != null) .WhereIf(p => p.CreatedNo >= param.StartTime.Value, param.StartTime.HasValue) .WhereIf(p => p.CreatedNo <= param.EndTime.Value, param.EndTime.HasValue) select new TrackingNumberID() { TrackingNumberId = tnInfo.TrackingNumberID }); model.TrackingNumberIds = list.ToList(); return(model); }