public ActionResult Index(Guid? id) { var page = new Paged {Length = 20}; var vm = new CategoryViewModel { Category = _serviceResource.GetCategory( id, page ), Paged = page }; return View(vm); }
public Category GetCategory(Guid? id, Paged paged) { var cat = id.HasValue ? RepoCategories.Get(x => x.Id == id.Value) : RepoCategories.Get(x => x.ParentId == null); DbEntityEntry<Category> entry = RepoCategories.Entry(cat); paged.Total = entry.Collection(x => x.Resources).Query().Count(); entry.Collection(x => x.Resources).Query().Include(x => x.Categories) .Where(x => true) .OrderBy(x => x.Id) .Skip(paged.Start) .Take(paged.Length) .Load(); entry.Collection(x => x.SubCategories).Query().Take(10).Load(); LoadParent(entry); return entry.Entity; }