本文整理汇总了C#中System.Collections.Generic.ToPagedList方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.ToPagedList方法的具体用法?C# System.Collections.Generic.ToPagedList怎么用?C# System.Collections.Generic.ToPagedList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.ToPagedList方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PageNumber_Above_RecordCount_Returns_Empty_List
public void PageNumber_Above_RecordCount_Returns_Empty_List()
{
//arrange
var data = new[] {1, 2, 3};
//act
var pagedList = data.ToPagedList(2, 3);
//assert
Assert.Equal(0, pagedList.Count);
}
示例2: Index
public ActionResult Index(int? page)
{
const int pageSize = 2;
var orders = new[]
{
new Order(new Customer {Name = "Jerry Seinfeld"}, new[]
{
new OrderLineItem(new Product("Superman Underoos", 17.99m), 7)
}),
new Order(new Customer {Name = "George Costanza"}, new[]
{
new OrderLineItem(new Product("Bosco", 4.99m), 15)
}),
new Order(new Customer {Name = "Cosmo Kramer"}, new[]
{
new OrderLineItem(new Product("Door Knobs", 7.95m), 30)
}),
new Order(new Customer {Name = "Elaine Benes"}, new[]
{
new OrderLineItem(new Product("Sponge", 6.95m), 500)
}),
new Order(new Customer {Name = "Newman"}, new[]
{
new OrderLineItem(new Product("Dinosaur Samples", 1500000m), 1)
})
};
var pagedOrders = orders.ToPagedList(page ?? 1, pageSize);
Mapper.CreateMap<Order, OrderDto>(); // create mapping between Order and OrderDto
var dtoOrders = Mapper.Map<IEnumerable<Order>, IEnumerable<OrderDto>>(pagedOrders); // convert all the Orders in the paged list into OrderDtos
var dto = new StaticPagedList<OrderDto>(dtoOrders, pagedOrders); // reconsitute a new paged list containing the OrderDtos
return View(dto);
}
示例3: DataSet_Of_One_Through_Five_PageSize_Of_Two_PageNumber_Of_Two_First_Item_Is_Three
public void DataSet_Of_One_Through_Five_PageSize_Of_Two_PageNumber_Of_Two_First_Item_Is_Three()
{
//arrange
var data = new[] {1, 2, 3, 4, 5};
//act
var pagedList = data.ToPagedList(2, 2);
//assert
Assert.Equal(3, pagedList[0]);
}
示例4: DataSet_OneAndTwo_PageSize_One_PageNumber_Two_FirstValue_Is_Two
public void DataSet_OneAndTwo_PageSize_One_PageNumber_Two_FirstValue_Is_Two()
{
//arrange
var data = new[] { 1, 2 };
//act
var pagedList = data.ToPagedList(2, 1);
//assert
Assert.Equal(2, pagedList[0]);
}
示例5: DataSet_OneThroughThree_PageSize_One_PageNumber_Three_IsLastPage_True
public void DataSet_OneThroughThree_PageSize_One_PageNumber_Three_IsLastPage_True()
{
//arrange
var data = new[] {1, 2, 3};
//act
var pagedList = data.ToPagedList(3, 1);
//assert
Assert.Equal(true, pagedList.IsLastPage);
}
示例6: DataSet_OneThroughThree_PageSize_One_PageNumber_Three_HasNextPage_False
public void DataSet_OneThroughThree_PageSize_One_PageNumber_Three_HasNextPage_False()
{
//arrange
var data = new[] {1, 2, 3};
//act
var pagedList = data.ToPagedList(3, 1);
//assert
Assert.Equal(false, pagedList.HasNextPage);
}
示例7: DataSet_OneThroughSix_PageSize_Three_PageNumber_One_FirstValue_Is_One
public void DataSet_OneThroughSix_PageSize_Three_PageNumber_One_FirstValue_Is_One()
{
//arrange
var data = new[] { 1, 2, 3, 4, 5, 6 };
//act
var pagedList = data.ToPagedList(1, 3);
//assert
Assert.Equal(1, pagedList[0]);
}
示例8: Data_Is_Filtered_By_PageSize
public void Data_Is_Filtered_By_PageSize()
{
//arrange
var data = new[] {1, 2, 3, 4, 5};
//act
var pagedList = data.ToPagedList(2, 2);
//assert
Assert.Equal(2, pagedList.Count);
//### related test below
//act
pagedList = data.ToPagedList(3, 2);
//assert
Assert.Equal(1, pagedList.Count);
}
示例9: PageSize_Is_Preserved
public void PageSize_Is_Preserved()
{
//arrange
var data = new[] {1, 2, 3, 4, 5};
//act
var pagedList = data.ToPagedList(2, 2);
//assert
Assert.Equal(2, pagedList.PageSize);
}
示例10: TotalCount_Is_Preserved
public void TotalCount_Is_Preserved()
{
//arrange
var data = new[] {1, 2, 3, 4, 5};
//act
var pagedList = data.ToPagedList(2, 2);
//assert
Assert.Equal(5, pagedList.TotalItemCount);
}
示例11: ToPagedList_ReturnsCollection
public void ToPagedList_ReturnsCollection()
{
IQueryable<int> integers = new[] { 1, 2, 3 }.AsQueryable();
var pagedList = integers.ToPagedList(0, 2);
Assert.AreEqual(2, pagedList.TotalPages);
}