本文整理汇总了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);
}