本文整理汇总了C#中PaginatedList.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# PaginatedList.ToList方法的具体用法?C# PaginatedList.ToList怎么用?C# PaginatedList.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaginatedList
的用法示例。
在下文中一共展示了PaginatedList.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Category
public ActionResult Category(string id,string sort="default",string order="asc",int pageIndex=0,int pageSize=2)
{
var products = _unitOfWork.ProductRepository.Get().ToList();//new ProductsBuilder().Build());
@ViewBag.Sort = sort;
@ViewBag.Order = order;
@ViewBag.PageSize = pageSize;
var category = _categories.First(i => i.Id==new Guid(id));
var allCategories = category.GetAllCategories();
var selectedProducts = products.Where(p => allCategories.Contains(p.CategoryId)).ToList();
var paginatedProducts = new PaginatedList<Product>(selectedProducts, pageIndex, pageSize);
var categoryViewModels = GetCategoriesByCategory(category, products);
var specialProduct = products.First(i => i.Id == new Guid("CD4879A0-C210-4DAA-A6DE-A59E9CC153BF"));
var specialProductViewModel = new SpecialProductViewModel
{
Id = specialProduct.Id.ToString(),
Name = specialProduct.Name,
OldPrice = specialProduct.OldPrice.HasValue? specialProduct.OldPrice.Value.ToString("C"):string.Empty,
NewPrice = specialProduct.NewPrice.ToString("C"),
RatingImagePath = specialProduct.RatingImagePath,
Image240x192Path = specialProduct.Image240x192Path
};
var refineSearchs = new List<RefineSearch>();
foreach (var childCategory in _categories.Where(c=>c.ParentCategory==category))
{
var refineSearch = new RefineSearch
{
Id = childCategory.Id.ToString(),
Name = childCategory.Name,
Total = products.Count(p => p.CategoryId == childCategory.Id)
};
refineSearchs.Add(refineSearch);
}
var productsBlock = GetProductsBlocks(paginatedProducts.ToList());
var categoryModel = new CategoryModel
{
Id=id,
Name=category.Name,
Description = category.Description,
ImagePath=category.ImagePath,
RefineSearches=refineSearchs,
CategoryViewModels=categoryViewModels,
SpecialProductViewModel=specialProductViewModel,
ProductsBlock=productsBlock,
PaginatedList=paginatedProducts
};
return View(categoryModel);
}
示例2: GetAllFunds
public Helpers.FundLists GetAllFunds(int pageIndex, int pageSize)
{
Helpers.FundLists funds = new Helpers.FundLists();
using (DeepBlueEntities context = new DeepBlueEntities()) {
IQueryable<Helpers.FundList> fundListQuery = (from fund in context.FundsTable
select new Helpers.FundList {
FundId = fund.FundID,
FundName = fund.FundName
});
fundListQuery = fundListQuery.OrderBy("FundName", true);
PaginatedList<Helpers.FundList> paginatedList = new PaginatedList<Helpers.FundList>(fundListQuery, pageIndex, pageSize);
funds.TotalPages = paginatedList.TotalPages;
funds.PageNo = pageIndex;
funds.FundDetails = paginatedList.ToList();
}
return funds;
}