public override ActionResult Export() { var req = new GridRequest(Request); var profilePredicate = FilterHelper.GetExpression <ArticleInfo>(req.FilterGroup); string strTitle = Request["txtArticleTitle"]; //string strNewsCate = AppId.ToString(); string txtDate = Request["txtDate"]; string strSubCate = Request["txtSubCate"]; profilePredicate = profilePredicate.AndAlso(a => a.IsDeleted == false); if (!string.IsNullOrEmpty(strTitle)) { profilePredicate = profilePredicate.AndAlso(a => a.ArticleTitle.Contains(strTitle)); } if (!string.IsNullOrEmpty(txtDate)) { DateTime dateTime = Convert.ToDateTime(txtDate); DateTime dateAdd = dateTime.AddDays(1); profilePredicate = profilePredicate.AndAlso(a => a.PublishDate >= dateTime && a.PublishDate <= dateAdd); } if (!string.IsNullOrEmpty(strSubCate)) { // ID变更为CategoryCode var cateInfo = CommonService.lstCategory.FirstOrDefault(a => a.Id == Convert.ToInt32(strSubCate) && a.IsDeleted == false); string categoryCode = cateInfo == null ? string.Empty : cateInfo.CategoryCode; //predicate = predicate.AndAlso(a => a.ArticleCateSub == strSubCate); profilePredicate = profilePredicate.AndAlso(a => a.ArticleCateSub == categoryCode); } var codes = (from item in CommonService.GetCategory(false).Where(a => a.IsAdmin.Value).ToList() select item.CategoryCode).ToList(); profilePredicate = profilePredicate.AndAlso(a => codes.Contains(a.ArticleCateSub) && !string.IsNullOrEmpty(a.ArticleCateSub)); var list = _objService.GetArticleList <ArticleInfoView>(profilePredicate); return(exportToCSV(list)); }