当前位置: 首页>>代码示例>>C#>>正文


C# PaginatedList.ToList方法代码示例

本文整理汇总了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);
        }
开发者ID:HaoTan,项目名称:APlusSecurityNZ,代码行数:55,代码来源:ProductController.cs

示例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;
 }
开发者ID:jsingh,项目名称:DeepBlue,代码行数:17,代码来源:FundRepository.cs


注:本文中的PaginatedList.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。