public JsonResult ListP(CategorySearchOption search, PagerRequest request) { int totalCount; var linq = Context.Set<CategoryEntity>().Where(p => (string.IsNullOrEmpty(search.Name) || p.Name.Contains(search.Name)) && (!search.PId.HasValue || p.ExCatId == search.PId.Value) && p.Status != (int)DataStatus.Deleted); var linq2 = linq.GroupJoin(Context.Set<CategoryMapEntity>().Where(u => u.Status != (int)DataStatus.Deleted), o => o.ExCatId, i => i.CatId, (o, i) => new { O = o, C = i }) ; totalCount = linq2.Count(); var skipCount = (request.PageIndex - 1) * request.PageSize; var linq3 = skipCount == 0 ? linq2.Take(request.PageSize) : linq2.Skip(skipCount).Take(request.PageSize); var vo = from l in linq3.ToList() select new CategoryViewModel().FromEntity<CategoryViewModel>(l.O, p => { p.ShowCategories = l.C.Select(c => new ShowCategoryViewModel() { ShowChannel = c.ShowChannel }).ToList() ; }); var v = new Pager<CategoryViewModel>(request, totalCount) { Data = vo.ToList() }; return Json(v); }
public ActionResult List(CategorySearchOption search) { return View(search); }