public List <Banner> getList(string type, string status) { Expression <Func <Banner, bool> > predicate = PredicateExtensionses.True <Banner>(); predicate = predicate.And(m => m.DeleteFlag == "N"); if (!string.IsNullOrEmpty(type)) { predicate = predicate.And(m => m.Type == type); } if (!string.IsNullOrEmpty(status)) { predicate = predicate.And(m => m.Status == status); } return(db.Banner.Where(predicate).OrderBy(m => m.OrderByNum).ToList <Banner>()); }
public List <Article> getPageList(int pageSize, int pageIndex, out int total, string keywords, int menuId) { Expression <Func <Article, bool> > predicate = PredicateExtensionses.True <Article>(); predicate = predicate.And(m => m.DeleteFlag == "N"); if (!string.IsNullOrEmpty(keywords)) { predicate = predicate.And(m => m.Title.Contains(keywords)); } if (menuId != null && menuId != 0) { predicate = predicate.And(m => m.MenuId == menuId); } total = db.Article.Where(predicate).Count(); return(db.Article.Where(predicate).OrderByDescending(m => m.Id).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList <Article>()); }