public IActionResult Index(PageParameter pageParams) { PageDataResponse <BannerDto> pageData = new PageDataResponse <BannerDto>(); var parameterExpression = System.Linq.Expressions.Expression.Parameter(typeof(Banner)); var filter = (System.Linq.Expressions.Expression)System.Linq.Expressions.Expression.Constant(true); if (!string.IsNullOrEmpty(pageParams.Key)) { pageParams.Key = pageParams.Key.Trim(); filter = (System.Linq.Expressions.Expression)System.Linq.Expressions.Expression.Constant(false); Guid guid = Guid.Empty; if (Guid.TryParse(pageParams.Key, out guid)) { filter = filter.GotoOrElse(parameterExpression.GotoEqual("ID", guid)); } } else { filter = filter.GotoOrElse(parameterExpression.GotoNotEqual("ID", Guid.Empty)); } if (pageParams.BeginTime != null && pageParams.EndTime != null && pageParams.BeginTime <= pageParams.EndTime) { filter = filter.GotoAndAlso(parameterExpression.GotoGreaterThanByDateTime("CreateTime", pageParams.BeginTime)); filter = filter.GotoAndAlso(parameterExpression.GotoLessThanByDateTime("CreateTime", pageParams.EndTime)); } var queryLambdaFilter = System.Linq.Expressions.Expression.Lambda <Func <Banner, bool> >(filter, parameterExpression); int Count; List <BannerDto> List = _BannerAppService.PageList(queryLambdaFilter, pageParams.PageSize, pageParams.CurPage, out Count); if (List.Any()) { Guid[] langIds = List.Select(a => a.LanguageTypeID).Distinct().ToArray(); var langList = _languageTypeAppService.QueryList(a => langIds.Contains(a.ID)); foreach (var item in List) { var temp = langList.FirstOrDefault(a => a.ID.Equals(item.LanguageTypeID)); if (temp != null) { item.LanguageTypeName = string.Format("{0}/{1}", temp.Code, temp.Title); } item.Image = Common.GetImgFullUrl(item.Image, Vic.Core.Utils.Enum.AM_Enum.ImgPathEnum.CmsImg, true); } } pageData.Data = List; pageData.TotalItem = Count; pageData.QueryData = pageParams; pageData.PageHTML = base.PageHtml(Count, pageParams.CurPage, pageParams.PageSize, this.HttpContext); return(View(pageData)); }