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


C# PaginatedList.InsertRange方法代码示例

本文整理汇总了C#中PaginatedList.InsertRange方法的典型用法代码示例。如果您正苦于以下问题:C# PaginatedList.InsertRange方法的具体用法?C# PaginatedList.InsertRange怎么用?C# PaginatedList.InsertRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PaginatedList的用法示例。


在下文中一共展示了PaginatedList.InsertRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Search


//.........这里部分代码省略.........
                            new char[0],
                            StringSplitOptions.RemoveEmptyEntries
                        )
                    );

                    // add the whole phrase by default if more
                    // than 1 word
                    if (keywords.Count > 1)
                        keywords.Add(search.Keywords);

                    // replace commas
                    for (int i = 0; i < keywords.Count; ++i)
                        keywords[i] = keywords[i].Replace(",", "");

                    // apply to Title, Description and Custom Amenities
                    listings = from b in listings
                               let ca = b.CustomAmenities.Select(a => a.Name)
                               where keywords.Any(k => b.Title.Contains(k)) ||
                               keywords.Any(k => b.Description.Contains(k)) ||
                               keywords.Any(k => ca.Any(a => a.Contains(k)))
                               select b;
                }

                // end of advanced

                // apply default ordering
                switch (search.OrderBy)
                {
                    case "NewOld":
                        //order by for priority listings, as well as date activated
                        listings = listings.OrderByDescending(l => l.HasPriority)
                                           .ThenByDescending(l => l.DateActivatedUtc);
                        break;
                    case "OldNew":
                        listings = listings.OrderBy(m => m.DateActivatedUtc);
                        break;
                    case "PriceHighLow":
                        listings = listings.OrderByDescending(m => m.Price);
                        break;
                    case "PriceLowHigh":
                        listings = listings.OrderBy(m => m.Price);
                        break;
                    case "DateAvailable":
                        break;
                    default:
                        listings = listings.OrderByDescending(l => l.HasPriority)
                                           .ThenByDescending(l => l.DateActivatedUtc);
                        break;
                }

                // convert to building preview
                var final = from b in listings
                            select new BuildingPreview()
                            {
                                Address1 = b.Address1,
                                Address2 = b.Address2,
                                Bathrooms = b.Bathrooms.Value,
                                Bedrooms = b.Bedrooms.Value,
                                BuildingId = b.BuildingId,
                                RibbonId = b.RibbonId,
                                City = b.City,
                                IsFeatured = false,
                                Price = b.Price,
                                PrimaryPhotoExtension = b.PrimaryPhotoExtension,
                                PrimaryPhotoId = b.PrimaryPhotoId,
                                State = b.State,
                                Title = b.Title,
                                IsActive = b.IsActive,
                                Latitude = b.Latitude,
                                Longitude = b.Longitude,
                                HasPriority = b.HasPriority,
                                DatePrioritized = b.DatePrioritized,
                                Zip = b.Zip
                            };

            #if DEBUG
                Tracer.OutputQuery<BuildingPreview>(final);
            #endif
                // get the results to show
                results = new PaginatedList<BuildingPreview>(
                    final,
                    search.Page,
                    search.ResultsPerPage
                );

                //grab featured items if we have any results
                if (results.Count > 0)
                    results.InsertRange(0, featured.Result);
            }

            // increment search views for each listing
            IncrementSearchViews(results.Select(m => m.BuildingId).ToArray());

            search.Results = results;

            search.HasNextPage = results.HasNextPage;
            search.HasPreviousPage = results.HasPreviousPage;

            return Status.OK<Search>(search);
        }
开发者ID:wes-cutting,项目名称:Sandbox-V2,代码行数:101,代码来源:ISearchAdapter.cs


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